This is the mail archive of the
mailing list for the binutils project.
Re: Possible bug; code-block vanishes when adding one assembler-instruction.
- From: Jens Bauer <jens-lists at gpio dot dk>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 8 May 2013 21:31:44 +0200
- Subject: Re: Possible bug; code-block vanishes when adding one assembler-instruction.
- References: <20130507122903314912 dot 0457de47 at gpio dot dk> <87sj1xv0bs dot fsf at talisman dot default>
On Wed, 08 May 2013 18:38:31 +0100, Richard Sandiford wrote:
> Jens Bauer <email@example.com> writes:
>> Now, one interesting thing is that the disassembly looks just fine to
>> me, so does the linker map.
>> I'm using gcc -x assembler-with-cpp for assembling, and g++ for linking.
>> Since the disassembly looks fine and the linker map looks fine and the
>> hex file looks wrong, I suspect that it has to do with objcopy.
> Probably a daft question, sorry, but do you mean the disassembly of
> the linked .elf file rather than the .o file?
All questions are valid. :)
Yes, I am disassembling the .elf file; I'm using...
$(OBJDUMP) -Mreg-names-std -D $(TARGET).elf >$(TARGET).dis
...I'd like to use the -d option if I could add a single section; eg. ".fastcode", but I haven't found out how to do this, if that's possible.
As I understand it, -d disassembles all the executable sections, but I can't seem to find out how to mark a section 'executable' either.
> If so, then I agree
> objcopy sounds like the most likely culprit.
> Out of interest, do you get the same weirdness if you drop the:
>> This is the objcopy part of my Makefile:
>> $(PROJECT).hex: $(PROJECT).elf
>> $(OBJCOPY) -R .stack -O ihex $(PROJECT).elf $(PROJECT).hex
> -R .stack from here? (I realise that might not give a viable executable.
> It'd just be interesting to know whether the same weirdness was visible.)
I just tried it; there seem to be no difference in the .fastcode section.
> Have you tried using the linker script to discard the sections you don't
> need, e.g. via DISCARD?
I think I need some education on DISCARD. My linker said "Illegal use of `/DISCARD/´ section", which means I haven't understood it right yet. ;)
Could you give a short example on what you mean ?
I just tried manually removing all sections, except from bare .text and .fastcode...
(Text is needed, as it refers a label in .fastcode)
-The code block is still 'turned on' / 'turned off' by commenting out the 'str' instruction.
To make it easy for you to see if you get the same error, I've created an archive, which should test it automatically.
You should be able to test it by unarchiving the files then running...
$ cd Fcode-test; cat TestIt
...after verifying that the script (and the Makefile) can be trusted, you can run it using something like...
$ chmod 755 TestIt; ./TestIt
...OK, here's the archive: