+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
 
          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;
            }
 
+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
 
 
--- /dev/null
+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;
+}
 
--- /dev/null
+extern int eight (void);
+
+int
+main (void)
+{
+  return eight () - 8;
+}
 
   {"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
     {"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.