This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible bug; code-block vanishes when adding one assembler-instruction.


Hi Richard.

On Wed, 08 May 2013 18:38:31 +0100, Richard Sandiford wrote:
> Jens Bauer <jens-lists@gpio.dk> 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:

<http://scratch.gpio.dk/Fcode-Test.zip>


Love
Jens


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]