This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: 2.10.91: A problem with LINK_ONCE_DISCARD sections on mipsel-linux
- To: "Maciej W. Rozycki" <macro at ds2 dot pg dot gda dot pl>
- Subject: Re: 2.10.91: A problem with LINK_ONCE_DISCARD sections on mipsel-linux
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Thu, 5 Oct 2000 15:54:41 +1100 (EST)
- cc: binutils at sourceware dot cygnus dot com, Ulf Carlsson <ulfc at engr dot sgi dot com>, Ian Lance Taylor <ian at zembu dot com>
On Tue, 3 Oct 2000, Maciej W. Rozycki wrote:
> Hmm, maybe we could mark such symbols global?...
This patch does the trick.
bfd/ChangeLog
* elf.c (swap_out_syms): Handle global section symbols.
gas/ChangeLog
* config/obj-elf.c (elf_frob_symbol): Make section syms global on
link-once sections.
Not installed yet, because I'd like to hear from Ian (and any other ELF
expert who'd like to comment) whether this is a wise move. Grepping
through the code says it's unlikely to break any port, with the
possibile exception of elf32-mips.
Alan Modra
--
Linuxcare. Support for the Revolution.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.55
diff -u -p -r1.55 elf.c
--- elf.c 2000/09/30 00:44:49 1.55
+++ elf.c 2000/10/05 04:23:47
@@ -4346,8 +4346,9 @@ swap_out_syms (abfd, sttp, relocatable_p
flagword flags = syms[idx]->flags;
int type;
- if (flags & BSF_SECTION_SYM)
- /* Section symbols have no names. */
+ /* Section symbols usually have no name. The exception is
+ link-once section symbols, which we make global. */
+ if ((flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM)
sym.st_name = 0;
else
{
@@ -4455,7 +4456,8 @@ swap_out_syms (abfd, sttp, relocatable_p
type = (*bed->elf_backend_get_symbol_type) (&type_ptr->internal_elf_sym, type);
if (flags & BSF_SECTION_SYM)
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_info = ELF_ST_INFO ((flags & BSF_GLOBAL
+ ? STB_GLOBAL : STB_LOCAL), STT_SECTION);
else if (bfd_is_com_section (syms[idx]->section))
sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
else if (bfd_is_und_section (syms[idx]->section))
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.21
diff -u -p -r1.21 obj-elf.c
--- obj-elf.c 2000/09/14 11:48:26 1.21
+++ obj-elf.c 2000/10/05 04:24:43
@@ -1742,6 +1742,21 @@ elf_frob_symbol (symp, puntp)
&& S_IS_DEFINED (symp))
symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
+
+ if (symbol_section_p (symp))
+ {
+ asection *symsec = S_GET_SEGMENT (symp);
+
+ if ((bfd_get_section_flags (stdoutput, symsec) & SEC_LINK_ONCE) != 0
+ || strncmp (segment_name (symsec), ".gnu.linkonce",
+ sizeof ".gnu.linkonce" - 1) == 0)
+ {
+ /* Make section syms global on ELF linkonce sections.
+ This way, any reference to the section symbol will
+ resolve to the section that actually stays in. */
+ S_SET_EXTERNAL (symp);
+ }
+ }
}
void