aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-12-23 19:07:23 +1030
committerAlan Modra <amodra@gmail.com>2014-12-23 23:36:50 +1030
commit12b2843a6bb12292d8e36d8df22c788a3c91cb2f (patch)
tree09f7f27839b1e5fe160a58612b5939037905e968 /ld
parent4cc2bf08a4e18aa2009e9d4f1694a800eacbee17 (diff)
downloadgdb-12b2843a6bb12292d8e36d8df22c788a3c91cb2f.zip
gdb-12b2843a6bb12292d8e36d8df22c788a3c91cb2f.tar.gz
gdb-12b2843a6bb12292d8e36d8df22c788a3c91cb2f.tar.bz2
Use a symbol flag bit to mark linker defined symbols
Trying to use the SEC_LINKER_CREATED section flag to determine whether a symbol is linker defined fails to work on targets like alpha that define special SEC_COMMON sections. These might contain symbols that originated in an object file. include/ * bfdlink.h (struct bfd_link_hash_entry): Comment non_ir_ref. Add linker_def. bfd/ * elflink.c (_bfd_elf_define_linkage_sym): Set linker_def. * linker.c (_bfd_generic_link_add_one_symbol): Clear linker_def for CDEF, DEF, DEFW, COM. ld/ * ldexp.c (exp_fold_tree_1 <etree_provide>): Test linker_def. ld/testsuite/ * ld-powerpc/sdabase.s, * ld-powerpc/sdabase.t, * ld-powerpc/sdabase.d: New test. * ld-powerpc/sdabase2.t, * ld-powerpc/sdabase2.d: New test. * ld-powerpc/powerpc.exp: Run them.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog4
-rw-r--r--ld/ldexp.c4
-rw-r--r--ld/testsuite/ChangeLog9
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp2
-rw-r--r--ld/testsuite/ld-powerpc/sdabase.d10
-rw-r--r--ld/testsuite/ld-powerpc/sdabase.s9
-rw-r--r--ld/testsuite/ld-powerpc/sdabase.t6
-rw-r--r--ld/testsuite/ld-powerpc/sdabase2.d10
-rw-r--r--ld/testsuite/ld-powerpc/sdabase2.t6
9 files changed, 57 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index f16d1d5..7f6eca2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,9 @@
2014-12-23 Alan Modra <amodra@gmail.com>
+ * ldexp.c (exp_fold_tree_1 <etree_provide>): Test linker_def.
+
+2014-12-23 Alan Modra <amodra@gmail.com>
+
* ldexp.c (exp_fold_tree_1 <etree_provide>): Leave bfd_link_hash_common
symbols alone.
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 8615869..b4af893 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1072,9 +1072,7 @@ exp_fold_tree_1 (etree_type *tree)
if (h == NULL
|| !(h->type == bfd_link_hash_new
|| h->type == bfd_link_hash_undefined
- || (h->type == bfd_link_hash_defined
- && (h->u.def.section->flags
- & SEC_LINKER_CREATED) != 0)))
+ || h->linker_def))
{
/* Do nothing. The symbol was never referenced, or
was defined in some object file. Undefined weak
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index c901bb7..cfc0284 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2014-12-23 Alan Modra <amodra@gmail.com>
+ * ld-powerpc/sdabase.s,
+ * ld-powerpc/sdabase.t,
+ * ld-powerpc/sdabase.d: New test.
+ * ld-powerpc/sdabase2.t,
+ * ld-powerpc/sdabase2.d: New test.
+ * ld-powerpc/powerpc.exp: Run them.
+
+2014-12-23 Alan Modra <amodra@gmail.com>
+
* ld-elf/endsym.s, *ld-elf/endsym.d: New test.
2014-12-19 Matthew Fortune <matthew.fortune@imgtec.com>
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 599b980..645236d 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -289,6 +289,8 @@ if { [istarget "powerpc*-eabi*"] } {
}
run_dump_test "plt1"
+run_dump_test "sdabase"
+run_dump_test "sdabase2"
run_dump_test "attr-gnu-4-00"
run_dump_test "attr-gnu-4-01"
diff --git a/ld/testsuite/ld-powerpc/sdabase.d b/ld/testsuite/ld-powerpc/sdabase.d
new file mode 100644
index 0000000..c54f750
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/sdabase.d
@@ -0,0 +1,10 @@
+#source: sdabase.s
+#as: -a32
+#ld: -melf32ppc -T sdabase.t
+#objdump: -s
+#target: powerpc*-*-*
+
+.*: file format .*
+
+Contents of section \.sdata:
+ 0400 (00008400|00840000) (00000400|00040000) .*
diff --git a/ld/testsuite/ld-powerpc/sdabase.s b/ld/testsuite/ld-powerpc/sdabase.s
new file mode 100644
index 0000000..8c85688
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/sdabase.s
@@ -0,0 +1,9 @@
+ .text
+ .globl _start
+_start:
+
+ .section .sdata,"aw",@progbits
+ .globl my_sdata
+my_sdata:
+ .dc.a _SDA_BASE_
+ .dc.a my_sdata
diff --git a/ld/testsuite/ld-powerpc/sdabase.t b/ld/testsuite/ld-powerpc/sdabase.t
new file mode 100644
index 0000000..2486962
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/sdabase.t
@@ -0,0 +1,6 @@
+SECTIONS
+{
+ .text 0x100 : { *(.text) }
+ .sdata 0x400 : { *(.sdata) }
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-powerpc/sdabase2.d b/ld/testsuite/ld-powerpc/sdabase2.d
new file mode 100644
index 0000000..a0da6f5
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/sdabase2.d
@@ -0,0 +1,10 @@
+#source: sdabase.s
+#as: -a32
+#ld: -melf32ppc -T sdabase2.t
+#objdump: -s
+#target: powerpc*-*-*
+
+.*: file format .*
+
+Contents of section \.sdata:
+ 0400 (00000400|00040000) (00000400|00040000) .*
diff --git a/ld/testsuite/ld-powerpc/sdabase2.t b/ld/testsuite/ld-powerpc/sdabase2.t
new file mode 100644
index 0000000..2a8f5d0
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/sdabase2.t
@@ -0,0 +1,6 @@
+SECTIONS
+{
+ .text 0x100 : { *(.text) }
+ .sdata 0x400 : { PROVIDE (_SDA_BASE_ = .); *(.sdata) }
+ /DISCARD/ : { *(*) }
+}