2009-06-17 H.J. Lu <hongjiu.lu@intel.com>
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 17 Jun 2009 18:08:35 +0000 (18:08 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 17 Jun 2009 18:08:35 +0000 (18:08 +0000)
* elf32-arm.c (create_got_section): Get existing .rela.got
section.
* elf32-hppa.c (elf32_hppa_create_dynamic_sections): Likewise.
* elf32-lm32.c (create_got_section): Likewise.
* elf32-m32r.c (create_got_section): Likewise.
* elf32-ppc.c (ppc_elf_create_got): Likewise.
* elf32-s390.c (create_got_section): Likewise.
* elf32-sh.c (create_got_section): Likewise.
* elf32-xtensa.c (elf_xtensa_create_dynamic_sections): Likewise.
* elf64-s390.c (create_got_section): Likewise.
* elfxx-sparc.c (create_got_section): Likewise.

* elflink.c (_bfd_elf_create_got_section): Properly initialize
the GOT size.

12 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
bfd/elf32-hppa.c
bfd/elf32-lm32.c
bfd/elf32-m32r.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-xtensa.c
bfd/elf64-s390.c
bfd/elflink.c
bfd/elfxx-sparc.c

index ad5fd4f0240c5d71c0992a23df2b7fe5ea119ba1..15e73e9fb2e34713b5f47151e8e04a89a44fabd5 100644 (file)
@@ -1,3 +1,20 @@
+2009-06-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-arm.c (create_got_section): Get existing .rela.got
+       section.
+       * elf32-hppa.c (elf32_hppa_create_dynamic_sections): Likewise.
+       * elf32-lm32.c (create_got_section): Likewise.
+       * elf32-m32r.c (create_got_section): Likewise.
+       * elf32-ppc.c (ppc_elf_create_got): Likewise.
+       * elf32-s390.c (create_got_section): Likewise.
+       * elf32-sh.c (create_got_section): Likewise.
+       * elf32-xtensa.c (elf_xtensa_create_dynamic_sections): Likewise.
+       * elf64-s390.c (create_got_section): Likewise.
+       * elfxx-sparc.c (create_got_section): Likewise.
+
+       * elflink.c (_bfd_elf_create_got_section): Properly initialize
+       the GOT size.
+
 2009-06-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf-bfd.h (ELF_LOCAL_SYMBOL_HASH): New.
index e1f569b64f08101a827b0e3df7c1a9bbdfea5411..45a94c70155b8e966a60eec3c917ba6c21395991 100644 (file)
@@ -2748,15 +2748,9 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   if (!htab->sgot || !htab->sgotplt)
     abort ();
 
-  htab->srelgot = bfd_make_section_with_flags (dynobj,
-                                              RELOC_SECTION (htab, ".got"),
-                                              (SEC_ALLOC | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
+  htab->srelgot = bfd_get_section_by_name (dynobj,
+                                          RELOC_SECTION (htab, ".got"));
+  if (htab->srelgot == NULL)
     return FALSE;
   return TRUE;
 }
index a83c4fd9ce874aee616832de93e9d30ef5aa1c08..20be2e79525d8d836b1c2296c59e58c50c865d41 100644 (file)
@@ -1011,16 +1011,7 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt");
 
   htab->sgot = bfd_get_section_by_name (abfd, ".got");
-  htab->srelgot = bfd_make_section_with_flags (abfd, ".rela.got",
-                                              (SEC_ALLOC
-                                               | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (abfd, htab->srelgot, 2))
-    return FALSE;
+  htab->srelgot = bfd_get_section_by_name (abfd, ".rela.got");
 
   htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss");
   htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss");
index 620dc506d16c67c394b7787a9e25fe621ebc45e3..bad0a7b94968b42e995a84d5113d586c3659f05f 100644 (file)
@@ -225,20 +225,10 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   htab = lm32_elf_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (! htab->sgot || ! htab->sgotplt)
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
 
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              (SEC_ALLOC
-                                               | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-
   return TRUE;
 }
 
index 96db6cbdff7b171186e86d5df9242dfbd5bc14f3..fd67e057d7a5df9d988549daf223a18fd7faf2c5 100644 (file)
@@ -1623,20 +1623,10 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   htab = m32r_elf_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (! htab->sgot || ! htab->sgotplt)
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
 
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              (SEC_ALLOC
-                                               | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-
   return TRUE;
 }
 
index dcf33cc3daa8b58a3b80936bf6930c2b0e05d5fa..c7ac2a134dd26c88ce00c18accf922eac5868575 100644 (file)
@@ -2845,12 +2845,9 @@ ppc_elf_create_got (bfd *abfd, struct bfd_link_info *info)
        return FALSE;
     }
 
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
-          | SEC_LINKER_CREATED | SEC_READONLY);
-  htab->relgot = bfd_make_section_with_flags (abfd, ".rela.got", flags);
-  if (!htab->relgot
-      || ! bfd_set_section_alignment (abfd, htab->relgot, 2))
-    return FALSE;
+  htab->relgot = bfd_get_section_by_name (abfd, ".rela.got");
+  if (!htab->relgot)
+    abort ();
 
   return TRUE;
 }
index 14c4cb0c998278ae16af273c0da4343318250dea..531f9e6a852b5293b1ca55ccff043b98bbacf27c 100644 (file)
@@ -821,18 +821,10 @@ create_got_section (dynobj, info)
   htab = elf_s390_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (!htab->sgot || !htab->sgotplt)
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  if (!htab->sgot || !htab->sgotplt || !htab->srelgot)
     abort ();
 
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              (SEC_ALLOC | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
   return TRUE;
 }
 
index 89cef677696d8dd208870328023dab0553f8ab74..555d900f64c52a8690e7ec1b341e3a36eb8f26c4 100644 (file)
@@ -2303,18 +2303,9 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   htab = sh_elf_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (! htab->sgot || ! htab->sgotplt)
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
-
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              (SEC_ALLOC | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
   return TRUE;
 }
 
index 09e81ad82eeba1bead1d51cb23d043f7558b3cf3..4200f6fbdb46af9c4340defb6461f3325dd77a59 100644 (file)
@@ -1404,6 +1404,7 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
 
   /* Create any extra PLT sections in case check_relocs has already
      been called on all the non-dynamic input files.  */
@@ -1419,12 +1420,6 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
       || ! bfd_set_section_flags (dynobj, htab->sgotplt, flags))
     return FALSE;
 
-  /* Create ".rela.got".  */
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", flags);
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-
   /* Create ".got.loc" (literal tables for use by dynamic linker).  */
   htab->sgotloc = bfd_make_section_with_flags (dynobj, ".got.loc", flags);
   if (htab->sgotloc == NULL
index 21a58649d9d996ba905eb666444537ec97eae0d6..c9bd764a44fbbb468b2599dd838001adb8fe41ce 100644 (file)
@@ -776,18 +776,9 @@ create_got_section (dynobj, info)
   htab = elf_s390_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (!htab->sgot || !htab->sgotplt)
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  if (!htab->sgot || !htab->sgotplt || !htab->srelgot)
     abort ();
-
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              (SEC_ALLOC | SEC_LOAD
-                                               | SEC_HAS_CONTENTS
-                                               | SEC_IN_MEMORY
-                                               | SEC_LINKER_CREATED
-                                               | SEC_READONLY));
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
-    return FALSE;
   return TRUE;
 }
 
index f1bceaed6b8e82f2edd3239073851975fe964af2..70bca46953e97adf1c95949fa373932d71c8ccac 100644 (file)
@@ -110,12 +110,6 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
 
   flags = bed->dynamic_sec_flags;
 
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
-  if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
-    return FALSE;
-  htab->sgot = s;
-
   s = bfd_make_section_with_flags (abfd,
                                   (bed->rela_plts_and_copies_p
                                    ? ".rela.got" : ".rel.got"),
@@ -126,6 +120,12 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
     return FALSE;
   htab->srelgot = s;
 
+  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+    return FALSE;
+  htab->sgot = s;
+
   if (bed->want_got_plt)
     {
       s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
@@ -136,6 +136,9 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
       htab->sgotplt = s;
     }
 
+  /* The first bit of the global offset table is the header.  */
+  s->size += bed->got_header_size;
+
   if (bed->want_got_sym)
     {
       /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
@@ -149,9 +152,6 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
        return FALSE;
     }
 
-  /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
-
   return TRUE;
 }
 \f
index 9acdfc4d3c948cac83ecbb8768db3cd4638d3d8f..9ec46179bef1acfd41819228d41c1ab9b04f4015 100644 (file)
@@ -899,13 +899,7 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
   BFD_ASSERT (htab->sgot != NULL);
 
-  htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-                                              SEC_ALLOC
-                                              | SEC_LOAD
-                                              | SEC_HAS_CONTENTS
-                                              | SEC_IN_MEMORY
-                                              | SEC_LINKER_CREATED
-                                              | SEC_READONLY);
+  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
   if (htab->srelgot == NULL
       || ! bfd_set_section_alignment (dynobj, htab->srelgot,
                                      htab->word_align_power))