binutils ld 2-32, defined in discarded section error

Alan Modra amodra@gmail.com
Thu Feb 14 07:06:00 GMT 2019


On Wed, Feb 13, 2019 at 07:20:12PM -0800, pierre willard wrote:
> Thanks for the answer. I am probably using a bad ld script file. My goal is
> to take a (big) object file, and create another (relocatable) object file
> with a bunch of sections removed.
> Basically I do : ld -r -o outputfile.o -Tscriptfile inputfile.o
> If my script file has a just a bunch of /DISCARD/  (nothing else) this
> command works (no error, sections are removed), but later on, when trying
> to use this outputfile.o, it says :  file not recognized: Bad value.

That might be because you're deleting too much, or it might be a ld
bug.

> If my script file has the original script (as per ld -r --verbose) with the
> added /DISCARD/ commands at the very end of that script, then this command
> fails with some symbol referenced in discarded section.

Well, sections that match the patterns in the script before /DISCARD/
won't be discarded.

> I guess there is no simple way to cleanly remove a section, while keeping
> the current file format. Right? (I tried objcopy -R option, but it does not
> remove related information, eg, relocation references).

objcopy -R should remove any relocs for the removed section.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list