This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] BFD: Handle copying of absolute section symbols
- From: Alan Modra <amodra at gmail dot com>
- To: "Maciej W. Rozycki" <macro at linux-mips dot org>, binutils at sourceware dot org, Richard Sandiford <rdsandiford at googlemail dot com>
- Date: Thu, 17 May 2012 15:59:20 +0930
- Subject: Re: [PATCH] BFD: Handle copying of absolute section symbols
- References: <alpine.LFD.2.00.1204090102360.19691@eddie.linux-mips.org> <20120410233400.GA24704@bubble.grove.modra.org> <alpine.LFD.2.00.1204161249480.19691@eddie.linux-mips.org> <20120416124817.GD3218@bubble.grove.modra.org> <alpine.LFD.2.00.1204161429070.19691@eddie.linux-mips.org> <20120417144802.GE3218@bubble.grove.modra.org> <alpine.LFD.2.00.1205070459480.3701@eddie.linux-mips.org> <20120507072141.GF17181@bubble.grove.modra.org>
On Mon, May 07, 2012 at 04:51:41PM +0930, Alan Modra wrote:
> On Mon, May 07, 2012 at 06:30:02AM +0100, Maciej W. Rozycki wrote:
> > 2012-05-07 Maciej W. Rozycki <macro@linux-mips.org>
> >
> > bfd/
> > * elf.c (elf_map_symbols): Never discard global section symbols.
>
> OK.
Let's commit both of your patches, and a comment fix.
2012-05-17 Maciej W. Rozycki <macro@linux-mips.org>
Alan Modra <amodra@gmail.com>
* elf.c (ignore_section_sym): Correct comment. Don't return
true for absolute section.
(elf_map_symbols): Move stray comment. Adjust for above change.
Don't discard global section symbols.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.554
diff -u -p -r1.554 elf.c
--- bfd/elf.c 16 May 2012 03:35:29 -0000 1.554
+++ bfd/elf.c 17 May 2012 03:44:07 -0000
@@ -3243,9 +3243,6 @@ assign_section_numbers (bfd *abfd, struc
return TRUE;
}
-/* Map symbol from it's internal number to the external number, moving
- all local symbols to be at the head of the list. */
-
static bfd_boolean
sym_is_global (bfd *abfd, asymbol *sym)
{
@@ -3260,7 +3257,7 @@ sym_is_global (bfd *abfd, asymbol *sym)
}
/* Don't output section symbols for sections that are not going to be
- output. */
+ output, or that are duplicates. */
static bfd_boolean
ignore_section_sym (bfd *abfd, asymbol *sym)
@@ -3268,9 +3265,13 @@ ignore_section_sym (bfd *abfd, asymbol *
return ((sym->flags & BSF_SECTION_SYM) != 0
&& !(sym->section->owner == abfd
|| (sym->section->output_section->owner == abfd
- && sym->section->output_offset == 0)));
+ && sym->section->output_offset == 0)
+ || bfd_is_abs_section (sym->section)));
}
+/* Map symbol from it's internal number to the external number, moving
+ all local symbols to be at the head of the list. */
+
static bfd_boolean
elf_map_symbols (bfd *abfd)
{
@@ -3312,7 +3313,8 @@ elf_map_symbols (bfd *abfd)
if ((sym->flags & BSF_SECTION_SYM) != 0
&& sym->value == 0
- && !ignore_section_sym (abfd, sym))
+ && !ignore_section_sym (abfd, sym)
+ && !bfd_is_abs_section (sym->section))
{
asection *sec = sym->section;
@@ -3326,12 +3328,10 @@ elf_map_symbols (bfd *abfd)
/* Classify all of the symbols. */
for (idx = 0; idx < symcount; idx++)
{
- if (ignore_section_sym (abfd, syms[idx]))
- continue;
- if (!sym_is_global (abfd, syms[idx]))
- num_locals++;
- else
+ if (sym_is_global (abfd, syms[idx]))
num_globals++;
+ else if (!ignore_section_sym (abfd, syms[idx]))
+ num_locals++;
}
/* We will be adding a section symbol for each normal BFD section. Most
@@ -3361,12 +3361,12 @@ elf_map_symbols (bfd *abfd)
asymbol *sym = syms[idx];
unsigned int i;
- if (ignore_section_sym (abfd, sym))
- continue;
- if (!sym_is_global (abfd, sym))
+ if (sym_is_global (abfd, sym))
+ i = num_locals + num_globals2++;
+ else if (!ignore_section_sym (abfd, sym))
i = num_locals2++;
else
- i = num_locals + num_globals2++;
+ continue;
new_syms[i] = sym;
sym->udata.i = i + 1;
}
--
Alan Modra
Australia Development Lab, IBM