bfd/
authorAlan Modra <amodra@gmail.com>
Wed, 20 Mar 2013 03:44:56 +0000 (03:44 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 20 Mar 2013 03:44:56 +0000 (03:44 +0000)
* elflink.c (_bfd_elf_make_dynamic_reloc_section): Override
sh_type according to is_rela.
ld/testsuite/
* ld-elf/rel.c, ld-elf/relmain.c, ld-elf/relmain.out: New test.
* ld-elf/shared.exp: Build and run it.

bfd/ChangeLog
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/rel.c [new file with mode: 0644]
ld/testsuite/ld-elf/relmain.c [new file with mode: 0644]
ld/testsuite/ld-elf/relmain.out [new file with mode: 0644]
ld/testsuite/ld-elf/shared.exp

index b710f3c5c2f681fbe58b6c3b9d88954344ec3265..d30bd2e701557991662e5d5374e3922a6b4dfb4c 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-20  Alan Modra  <amodra@gmail.com>
+
+       * elflink.c (_bfd_elf_make_dynamic_reloc_section): Override
+       sh_type according to is_rela.
+
 2013-03-18  Alan Modra  <amodra@gmail.com>
 
        PR ld/12549
index 8055d26ed7526abc618bcd857cce972f51661f8d..6ccf625882f39d3baa90778dd01d4bc5f85e5e46 100644 (file)
@@ -13025,6 +13025,11 @@ _bfd_elf_make_dynamic_reloc_section (asection *         sec,
          reloc_sec = bfd_make_section_anyway_with_flags (dynobj, name, flags);
          if (reloc_sec != NULL)
            {
+             /* _bfd_elf_get_sec_type_attr chooses a section type by
+                name.  Override as it may be wrong, eg. for a user
+                section named "auto" we'll get ".relauto" which is
+                seen to be a .rela section.  */
+             elf_section_type (reloc_sec) = is_rela ? SHT_RELA : SHT_REL;
              if (! bfd_set_section_alignment (dynobj, reloc_sec, alignment))
                reloc_sec = NULL;
            }
index 9d2fe1b972955d54ae3638eb4318c07ed56e911b..3dfdfa29c202148ff05a5a7af96d030672737733 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-20  Alan Modra  <amodra@gmail.com>
+
+       * ld-elf/rel.c, ld-elf/relmain.c, ld-elf/relmain.out: New test.
+       * ld-elf/shared.exp: Build and run it.
+
 2013-03-20  Alan Modra  <amodra@gmail.com>
            Will Newton <will.newton@linaro.org
 
diff --git a/ld/testsuite/ld-elf/rel.c b/ld/testsuite/ld-elf/rel.c
new file mode 100644 (file)
index 0000000..fd94f71
--- /dev/null
@@ -0,0 +1,9 @@
+static int seven = 7;
+static int *__attribute__((section("auto"))) auto_10 = &seven;
+
+int
+eight (void)
+{
+  extern int *__start_auto[], *__stop_auto[];
+  return *auto_10 + __stop_auto - __start_auto;
+}
diff --git a/ld/testsuite/ld-elf/relmain.c b/ld/testsuite/ld-elf/relmain.c
new file mode 100644 (file)
index 0000000..f72dd54
--- /dev/null
@@ -0,0 +1,7 @@
+extern int eight (void);
+
+int
+main (void)
+{
+  return eight () - 8;
+}
diff --git a/ld/testsuite/ld-elf/relmain.out b/ld/testsuite/ld-elf/relmain.out
new file mode 100644 (file)
index 0000000..e69de29
index 2feb73086c61d34e01b35689cb52c819ec6c7870..8a7590a1002fdc3b2a25c4896d9f33d4e44bf8a2 100644 (file)
@@ -203,6 +203,9 @@ set build_tests {
   {"Build needed1b.so with --no-copy-dt-needed-entries"
    "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
    {dummy.c} {} "needed1d.so"}
+  {"Build librel.so"
+   "-shared" "-fPIC"
+   {rel.c} {} "librel.so"}
 }
 
 run_cc_link_tests $build_tests
@@ -347,6 +350,9 @@ set run_tests {
     {"Link with --copy-dt-needed-entries"
      "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" ""
      {dummy.c} "needed1b" "needed1.out"}
+    {"Run relmain"
+     "--no-as-needed -rpath=tmpdir -Ltmpdir -lrel" ""
+     {relmain.c} "relmain" "relmain.out"}
 }
 
 # NetBSD ELF systems do not currently support the .*_array sections.