This is the mail archive of the 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.

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

--section=<section> (aka -j <section>) limits it to a particular section

> 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.


	.section .fastcode, "ax", @progbits

rather than:

	.section .fastcode

ought to do the trick.

>> 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.

Oh well, thanks for trying.

>> 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 ?

Normally you'd have a fake "section" like:

  /DISCARD/ : { *(.stack) }

I don't know whether there is something special about .stack on ARM
that stops that from working though.

> 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:
> <>

I'm afraid I don't have a full EABI toolchain to hand.  Could you upload
the .elf and .hex files?  That ought to be enough to see what objcopy
is doing.


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