]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix duplicate output section statement lookup
authorGuy Martin <gmsoft@tuxicoman.be>
Mon, 20 Jan 2014 03:46:16 +0000 (14:16 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 20 Jan 2014 03:51:36 +0000 (14:21 +1030)
Tie output section statements to their associated output section via
output section userdata.  This allows us to avoid hash lookups which
are slower and fail when multiple output sections have the same name.

* ldlang.h (lang_output_section_get): Define.
* ldlang.c (lang_output_section_get): Likewise.
(init_os): Set the output_section userdata to the output
section statement.
* emultempl/hppaelf.em: Use lang_output_section_get instead of
lang_output_section_find where applicable.
* emultempl/aarch64elf.em: Likewise.
* emultempl/aix.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/m68hc1xelf.em: Likewise.
* emultempl/metagelf.em: Likewise.
* emultempl/mipself.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/spuelf.em: Likewise.

12 files changed:
ld/ChangeLog
ld/emultempl/aarch64elf.em
ld/emultempl/aix.em
ld/emultempl/armelf.em
ld/emultempl/hppaelf.em
ld/emultempl/m68hc1xelf.em
ld/emultempl/metagelf.em
ld/emultempl/mipself.em
ld/emultempl/ppc64elf.em
ld/emultempl/spuelf.em
ld/ldlang.c
ld/ldlang.h

index ee26f6488906c3a372e027f688a28655bd3962ac..a022cba570014c63e0e3171b11b98354fa189272 100644 (file)
@@ -1,3 +1,21 @@
+2014-01-20  Guy Martin <gmsoft@tuxicoman.be>
+           Alan Modra  <amodra@gmail.com>
+
+       * ldlang.h (lang_output_section_get): Define.
+       * ldlang.c (lang_output_section_get): Likewise.
+       (init_os): Set the output_section userdata to the output
+       section statement.
+       * emultempl/hppaelf.em: Use lang_output_section_get instead of
+       lang_output_section_find where applicable.
+       * emultempl/aarch64elf.em: Likewise.
+       * emultempl/aix.em: Likewise.
+       * emultempl/armelf.em: Likewise.
+       * emultempl/m68hc1xelf.em: Likewise.
+       * emultempl/metagelf.em: Likewise.
+       * emultempl/mipself.em: Likewise.
+       * emultempl/ppc64elf.em: Likewise.
+       * emultempl/spuelf.em: Likewise.
+
 2014-01-17  Alan Modra  <amodra@gmail.com>
 
        * genscripts.sh (COMPILE_IN): Don't set if already set.
index b3279bf8850b49a8198a3fd41ebc21d5e1004c6c..b631feb9fbc70e2bbe9bef34039842a6b395b08a 100644 (file)
@@ -159,7 +159,6 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name,
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -173,8 +172,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name,
   bfd_set_section_alignment (stub_file->the_bfd, stub_sec, 3);
 
   output_section = input_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   info.input_section = input_section;
   lang_list_init (&info.add);
index 084bb664450ef77754e2c47ab694824fca71966f..d0801334d031b4118dcb0ca73745aaf61bc390f8 100644 (file)
@@ -854,7 +854,7 @@ gld${EMULATION_NAME}_before_allocation (void)
       /* Remove this section from the list of the output section.
         This assumes we know what the script looks like.  */
       is = NULL;
-      os = lang_output_section_find (sec->output_section->name);
+      os = lang_output_section_get (sec->output_section);
       if (os == NULL)
        einfo ("%P%F: can't find output section %s\n",
               sec->output_section->name);
index eee6af1259cb88eaed33def85bcb0685817bded1..85e924fcb24799ae28814adee374b19872fef598 100644 (file)
@@ -189,7 +189,6 @@ elf32_arm_add_stub_section (const char * stub_sec_name,
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -203,8 +202,7 @@ elf32_arm_add_stub_section (const char * stub_sec_name,
   bfd_set_section_alignment (stub_file->the_bfd, stub_sec, alignment_power);
 
   output_section = input_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   info.input_section = input_section;
   lang_list_init (&info.add);
index 65c1ea5e87a7b08531b8633d3fb62c7a620dce67..1b7e384f303f185879eaca92ee11f2b83560b263 100644 (file)
@@ -178,7 +178,6 @@ hppaelf_add_stub_section (const char *stub_sec_name, asection *input_section)
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -190,8 +189,7 @@ hppaelf_add_stub_section (const char *stub_sec_name, asection *input_section)
     goto err_ret;
 
   output_section = input_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   info.input_section = input_section;
   lang_list_init (&info.add);
index 594b193ca82664d50c9fef17df6f30e8174f3daf..4e1360f1d98758cecc831630e340c5ff01a35693 100644 (file)
@@ -250,7 +250,6 @@ m68hc11elf_add_stub_section (const char *stub_sec_name,
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -262,8 +261,7 @@ m68hc11elf_add_stub_section (const char *stub_sec_name,
     goto err_ret;
 
   output_section = tramp_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   /* Try to put the new section at the same place as an existing
      .tramp section.  Such .tramp section exists in most cases and
index 21e3e942edf4ad213461f16a0f32082aa40b3428..7760f814bd4d73167989da308dcd745a4f1720d7 100644 (file)
@@ -154,7 +154,6 @@ metagelf_add_stub_section (const char *stub_sec_name, asection *input_section)
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -166,8 +165,7 @@ metagelf_add_stub_section (const char *stub_sec_name, asection *input_section)
     goto err_ret;
 
   output_section = input_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   info.input_section = input_section;
   lang_list_init (&info.add);
index 3c6ec9fdb91a24bdabecac2c0c17a73221bfb1f0..02043b7bbfad8fa19faf5607d8919842774f0c82 100644 (file)
@@ -136,7 +136,6 @@ mips_add_stub_section (const char *stub_sec_name, asection *input_section,
 {
   asection *stub_sec;
   flagword flags;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -176,9 +175,7 @@ mips_add_stub_section (const char *stub_sec_name, asection *input_section,
   if (!bfd_set_section_flags (stub_bfd, stub_sec, flags))
     goto err_ret;
 
-  /* Create an output section statement.  */
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   /* Initialize a statement list that contains only the new statement.  */
   lang_list_init (&info.add);
index f2085d7dcf74c1eba9b600a0caaa8cec6d86add2..c126297883876b068d6ef6d19e1a70bfb0227feb 100644 (file)
@@ -378,7 +378,6 @@ ppc_add_stub_section (const char *stub_sec_name, asection *input_section)
   asection *stub_sec;
   flagword flags;
   asection *output_section;
-  const char *secname;
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
@@ -392,8 +391,7 @@ ppc_add_stub_section (const char *stub_sec_name, asection *input_section)
     goto err_ret;
 
   output_section = input_section->output_section;
-  secname = bfd_get_section_name (output_section->owner, output_section);
-  os = lang_output_section_find (secname);
+  os = lang_output_section_get (output_section);
 
   info.input_section = input_section;
   lang_list_init (&info.add);
index e14fa2637d8138b666ee436fa346b3da9a567579..8feb8bfa7f4e1b1ff2338df18d9d1c6a3ebd37b7 100644 (file)
@@ -138,8 +138,9 @@ spu_place_special_section (asection *s, asection *o, const char *output_name)
   lang_output_section_statement_type *os;
 
   if (o != NULL)
-    output_name = o->name;
-  os = lang_output_section_find (output_name);
+    os = lang_output_section_get (o);
+  else
+    os = lang_output_section_find (output_name);
   if (os == NULL)
     {
       os = gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
index 2a6c4c5e2ab550bd2aa48f46add1bcfeac396cc3..f6d713c22d6f97ed65c632fef4b3d6e29719b3a5 100644 (file)
@@ -1376,6 +1376,14 @@ lang_memory_default (asection * section)
   return lang_memory_region_lookup (DEFAULT_MEMORY_REGION, FALSE);
 }
 
+/* Get the output section statement directly from the userdata.  */
+
+lang_output_section_statement_type *
+lang_output_section_get (const asection *output_section)
+{
+  return get_userdata (output_section);
+}
+
 /* Find or create an output_section_statement with the given NAME.
    If CONSTRAINT is non-zero match one with that constraint, otherwise
    match any non-negative constraint.  If CREATE, always make a
@@ -2104,6 +2112,10 @@ init_os (lang_output_section_statement_type *s, flagword flags)
   s->bfd_section->output_section = s->bfd_section;
   s->bfd_section->output_offset = 0;
 
+  /* Set the userdata of the output section to the output section
+     statement to avoid lookup.  */
+  get_userdata (s->bfd_section) = s;
+
   /* If there is a base address, make sure that any sections it might
      mention are initialized.  */
   if (s->addr_tree != NULL)
index 6eb75dcff6e89c938fb408dfb6ab635959c352d0..e91153ca03e68b1d94e71eae0412eee8871942c3 100644 (file)
@@ -584,6 +584,8 @@ extern lang_input_statement_type *lang_add_input_file
   (const char *, lang_input_file_enum_type, const char *);
 extern void lang_add_keepsyms_file
   (const char *);
+extern lang_output_section_statement_type *lang_output_section_get
+  (const asection *);
 extern lang_output_section_statement_type *lang_output_section_statement_lookup
   (const char *, int, bfd_boolean);
 extern lang_output_section_statement_type *next_matching_output_section_statement