aboutsummaryrefslogtreecommitdiff
path: root/bfd/section.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-05-16 11:33:48 +0930
committerAlan Modra <amodra@gmail.com>2018-05-16 21:42:58 +0930
commit7cf7fcc83ca9fb4c4b591b3142bcf12e6e8a2aa5 (patch)
tree08fcdcea462df06c0945f3122fe0fb5f8c6f0930 /bfd/section.c
parentff329288d503d392de11f34ce64c7fdd3c62e50f (diff)
downloadgdb-7cf7fcc83ca9fb4c4b591b3142bcf12e6e8a2aa5.zip
gdb-7cf7fcc83ca9fb4c4b591b3142bcf12e6e8a2aa5.tar.gz
gdb-7cf7fcc83ca9fb4c4b591b3142bcf12e6e8a2aa5.tar.bz2
PR22458, failure to choose a matching ELF target
https://sourceware.org/ml/binutils/2013-05/msg00271.html was supposed to banish "file format is ambiguous" errors for ELF. It didn't, because the code supposedly detecting formats that implement match_priority didn't work. That was due to not placing all matching targets into the vector of matching targets. ELF objects should all match the generic ELF target (priority 2), plus one or more machine specific targets (priority 1), and perhaps a single machine specific target with OS/ABI set (priority 0, best match). So the armel object in the testcase actually matches elf32-littlearm, elf32-littlearm-symbian, and elf32-littlearm-vxworks (all priority 1), and elf32-little (priority 2). As the PR reported, elf32-little wasn't seen as matching. Fixing that part of the problem wasn't too difficult but matching the generic ELF target as well as the ARM ELF targets resulted in ARM testsuite failures. These proved to be the annoying reordering of stubs that occurs from time to time due to the stub names containing the section id. Matching another target causes more sections to be created in elf_object_p. If section ids change, stub names change, which results in different hashing and can therefore result in different hash table traversal and stub creation order. That particular problem is fixed by resetting section_id to the initial state before attempting each target match, and taking a snapshot of its value after a successful match. PR 22458 * format.c (struct bfd_preserve): Add section_id. (bfd_preserve_save, bfd_preserve_restore): Save and restore _bfd_section_id. (bfd_reinit): Set _bfd_section_id. (bfd_check_format_matches): Put all matches of any priority into matching_vector. Save initial section id and start each attempted match at that section id. * libbfd-in.h (_bfd_section_id): Declare. * section.c (_bfd_section_id): Rename from section_id and make global. Adjust uses. (bfd_get_next_section_id): Delete. * elf64-ppc.c (ppc64_elf_setup_section_lists): Replace use of bfd_get_section_id with _bfd_section_id. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/section.c')
-rw-r--r--bfd/section.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/bfd/section.c b/bfd/section.c
index 752f291..7ee3f69 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -820,21 +820,21 @@ _bfd_generic_new_section_hook (bfd *abfd, asection *newsect)
return TRUE;
}
-static unsigned int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */
+unsigned int _bfd_section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */
/* Initializes a new section. NEWSECT->NAME is already set. */
static asection *
bfd_section_init (bfd *abfd, asection *newsect)
{
- newsect->id = section_id;
+ newsect->id = _bfd_section_id;
newsect->index = abfd->section_count;
newsect->owner = abfd;
if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect)))
return NULL;
- section_id++;
+ _bfd_section_id++;
abfd->section_count++;
bfd_section_list_append (abfd, newsect);
return newsect;
@@ -1286,23 +1286,6 @@ bfd_make_section (bfd *abfd, const char *name)
/*
FUNCTION
- bfd_get_next_section_id
-
-SYNOPSIS
- int bfd_get_next_section_id (void);
-
-DESCRIPTION
- Returns the id that the next section created will have.
-*/
-
-int
-bfd_get_next_section_id (void)
-{
- return section_id;
-}
-
-/*
-FUNCTION
bfd_set_section_flags
SYNOPSIS