2004-12-01 Paul Brook <paul@codesourcery.com>
authorPaul Brook <paul@codesourcery.com>
Wed, 1 Dec 2004 23:23:12 +0000 (23:23 +0000)
committerPaul Brook <paul@codesourcery.com>
Wed, 1 Dec 2004 23:23:12 +0000 (23:23 +0000)
bfd/
* elflink.c (elf_link_add_object_symbols): Make symbols from discarded
sections undefined.
ld/testsuite/
* ld-elf/group1.d: New test.
* ld-elf/group.ld, ld-elf/group1a.s, ld-elf/group1b.s: New test.

bfd/ChangeLog
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/group.ld [new file with mode: 0644]
ld/testsuite/ld-elf/group1.d [new file with mode: 0644]
ld/testsuite/ld-elf/group1a.s [new file with mode: 0644]
ld/testsuite/ld-elf/group1b.s [new file with mode: 0644]

index 6a1d301b58453c08e6885ce2f34ec4d2c76a26d8..dc0d93308dfdf431255f96b3207749e09ab454ff 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-01  Paul Brook  <paul@codesourcery.com>
+
+       * elflink.c (elf_link_add_object_symbols): Make symbols from discarded
+       sections undefined.
+
 2004-11-30  Paul Brook  <paul@codesourcery.com>
 
        * elf32-arm.c (struct elf32_arm_link_hash_table): Remove
index b0953127de8681c4ef0b18f68e0cf8489856e7df..6e875960e1e3e2bf6de8eebd6d521e910099dabb 100644 (file)
@@ -3425,6 +3425,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
          sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
          if (sec == NULL)
            sec = bfd_abs_section_ptr;
+         else if (sec->kept_section)
+           {
+             /* Symbols from discarded section are undefined.  */
+             sec = bfd_und_section_ptr;
+             isym->st_shndx = SHN_UNDEF;
+           }
          else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
            value -= sec->vma;
        }
index 05f91c9f23d0f6b003cd3514def0c57be07b373c..d927189df6ed7bee83ec930fa94df5a6eed01a79 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-01  Paul Brook  <paul@codesourcery.com>
+
+       * ld-elf/group1.d: New test.
+       * ld-elf/group.ld, ld-elf/group1a.s, ld-elf/group1b.s: New test.
+
 2004-12-01  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * ld-selective/selective.exp: Use -print-libgcc-file-name for
diff --git a/ld/testsuite/ld-elf/group.ld b/ld/testsuite/ld-elf/group.ld
new file mode 100644 (file)
index 0000000..d6b27d0
--- /dev/null
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  . = 0x1000;
+  .text : { *(.text) }
+}
diff --git a/ld/testsuite/ld-elf/group1.d b/ld/testsuite/ld-elf/group1.d
new file mode 100644 (file)
index 0000000..d2f1b58
--- /dev/null
@@ -0,0 +1,9 @@
+#source: group1a.s
+#source: group1b.s
+#ld: -T group.ld
+#readelf: -s
+Symbol table '.symtab' contains .* entries:
+#...
+    .*: 00001000     0 NOTYPE  WEAK   DEFAULT    . foo
+    .*: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND bar
+#...
diff --git a/ld/testsuite/ld-elf/group1a.s b/ld/testsuite/ld-elf/group1a.s
new file mode 100644 (file)
index 0000000..296e76e
--- /dev/null
@@ -0,0 +1,4 @@
+       .section .text,"axG",%progbits,foo_group,comdat
+       .weak foo
+foo:
+       .word 0
diff --git a/ld/testsuite/ld-elf/group1b.s b/ld/testsuite/ld-elf/group1b.s
new file mode 100644 (file)
index 0000000..b66cba9
--- /dev/null
@@ -0,0 +1,6 @@
+       .section .text,"axG",%progbits,foo_group,comdat
+       .global foo
+       .global bar
+foo:
+       .word 0
+bar: