This is the mail archive of the binutils@sources.redhat.com 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: Linker is broken


On Wed, May 26, 2004 at 07:43:35PM +0930, Alan Modra wrote:
> OK, I've audited places that set SEC_EXCLUDE and think I have it all
> sorted out.  SEC_EXCLUDE, as the comment says in sections.c, is really
> only meant for final linking, but it may be set by various ELF backend
> section_from_shdr functions, where the type of linker operation, if any,
> isn't available.  We do want to ignore SEC_EXCLUDE in these cases if
> doing a relocatable link.  However, the linker should act on SEC_EXCLUDE
> set by bfd/stabs.c during relocatable linking.  That's the reason for
> the SEC_DEBUGGING test.
> 
> The cleanest solution that I can see to the current problem is to
> twiddle SEC_EXCLUDE in ldlang.c:lang_add_section.  Then all later linker
> code can simply test SEC_EXCLUDE without worrying about SEC_DEBUGGING
> and link_info.relocatable.
> 
> 	* elf.c (_bfd_elf_make_section_from_shdr): Don't set SEC_EXCLUDE
> 	for SHT_GROUP sections.

objdump -n won't show SEC_EXCLUDE on SHT_GROUP sections now.

> 	* ldlang.c (lang_add_section): Set SEC_EXCLUDE for SEC_GROUP
> 	sections when doing a final link.  Clear SEC_EXCLUDE when doing
> 	a relocable link, except for SEC_DEBUGGING sections.

It seems broken to me if we rely on linker to set/clear SEC_EXCLUDE
since there are many other SEC_EXCLUDE sections, which aren't set and
cleared by linker. I am not sure it will work on SHF_EXCLUDE sections.
I think we should test ld -r, SEC_DEBUGGING and SEC_EXCLUDE together
when deciding if a section can be ignored.

> 	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Use the
> 	same condition here to drop SEC_EXCLUDE orphan sections.


H.J.


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