diff options
author | Alan Modra <amodra@gmail.com> | 2015-09-18 09:14:25 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-09-18 12:39:16 +0930 |
commit | 975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6 (patch) | |
tree | 1e0766556406a33ec0f6fcd83b270087ae88897f /ld/testsuite | |
parent | b29b8669ad250df649a0f02c5575e7163a2cd9e4 (diff) | |
download | gdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.zip gdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.tar.gz gdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.tar.bz2 |
Delay converting linker script defined symbols from absolute
Giving linker script symbols defined outside of output sections a
section-relative value early, leads to them being used in expressions
as if they were defined inside an output section. This can mean loss
of the section VMA, and wrong results.
ld/
PR ld/18963
* ldexp.h (struct ldexp_control): Add rel_from_abs.
(ldexp_finalize_syms): Declare.
* ldexp.c (new_rel_from_abs): Keep absolute for expressions
outside of output section statements. Set rel_from_abs.
(make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs.
(struct definedness_hash_entry): Add final_sec, and comment.
(update_definedness): Set final_sec.
(set_sym_sections, ldexp_finalize_syms): New functions.
* ldlang.c (lang_process): Call ldexp_finalize_syms.
ld/testsuite
PR ld/18963
* ld-scripts/pr18963.d,
* ld-scripts/pr18963.t: New test.
* ld-scripts/expr.exp: Run it.
* ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute.
* ld-mips-elf/gp-hidden.sd: Don't care about _gp section.
* ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at
start of .data section.
* ld-mips-elf/no-shared-1-n64.d: Likewise.
* ld-mips-elf/no-shared-1-o32.d: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ChangeLog | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/provide-hidden-2.ld | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/gp-hidden.sd | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/no-shared-1-n32.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/no-shared-1-n64.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/no-shared-1-o32.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/expr.exp | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/pr18963.d | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/pr18963.t | 25 |
9 files changed, 65 insertions, 5 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 9629dda..575d048 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2015-09-18 Alan Modra <amodra@gmail.com> + + PR ld/18963 + * ld-scripts/pr18963.d, + * ld-scripts/pr18963.t: New test. + * ld-scripts/expr.exp: Run it. + * ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute. + * ld-mips-elf/gp-hidden.sd: Don't care about _gp section. + * ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at + start of .data section. + * ld-mips-elf/no-shared-1-n64.d: Likewise. + * ld-mips-elf/no-shared-1-o32.d: Likewise. + 2015-09-11 H.J. Lu <hongjiu.lu@intel.com> * ld-plugin/lto.exp (lto_link_tests): Add a "ld -r" test for diff --git a/ld/testsuite/ld-elf/provide-hidden-2.ld b/ld/testsuite/ld-elf/provide-hidden-2.ld index 0b04c49..17e526b 100644 --- a/ld/testsuite/ld-elf/provide-hidden-2.ld +++ b/ld/testsuite/ld-elf/provide-hidden-2.ld @@ -1,7 +1,7 @@ SECTIONS { . = 0x12300000; - PROVIDE_HIDDEN (foo = . + 0x11100000); + PROVIDE_HIDDEN (foo = ABSOLUTE (.) + 0x11100000); .data : { *(.data) } .got : { *(.got) } .interp : { *(.interp) } diff --git a/ld/testsuite/ld-mips-elf/gp-hidden.sd b/ld/testsuite/ld-mips-elf/gp-hidden.sd index 2e9cfbf..620eb9a 100644 --- a/ld/testsuite/ld-mips-elf/gp-hidden.sd +++ b/ld/testsuite/ld-mips-elf/gp-hidden.sd @@ -5,5 +5,5 @@ Symbol table '.dynsym' contains [0-9]+ entries: Symbol table '.symtab' contains [0-9]+ entries: * Num: * Value * Size * Type * Bind * Vis * Ndx * Name #... - * [0-9a-f]+: * [0-9a-f]+ * 0 * NOTYPE * LOCAL * DEFAULT * ABS * _gp + * [0-9a-f]+: * [0-9a-f]+ * 0 * NOTYPE * LOCAL * DEFAULT .* _gp #pass diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-n32.d b/ld/testsuite/ld-mips-elf/no-shared-1-n32.d index 04c466e..6a55008 100644 --- a/ld/testsuite/ld-mips-elf/no-shared-1-n32.d +++ b/ld/testsuite/ld-mips-elf/no-shared-1-n32.d @@ -16,7 +16,7 @@ Disassembly of section \.text: #... Disassembly of section \.data: -00060000 <\.data>: +00060000 .*: 60000: 00068000 .* #... Disassembly of section \.got: diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-n64.d b/ld/testsuite/ld-mips-elf/no-shared-1-n64.d index 0c91921..5813b30 100644 --- a/ld/testsuite/ld-mips-elf/no-shared-1-n64.d +++ b/ld/testsuite/ld-mips-elf/no-shared-1-n64.d @@ -15,7 +15,7 @@ Disassembly of section \.text: #... Disassembly of section \.data: -0000000000060000 <\.data>: +0000000000060000 .*: 60000: 00000000 .* 60004: 00068000 .* #... diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-o32.d b/ld/testsuite/ld-mips-elf/no-shared-1-o32.d index b67737f..53bac9e 100644 --- a/ld/testsuite/ld-mips-elf/no-shared-1-o32.d +++ b/ld/testsuite/ld-mips-elf/no-shared-1-o32.d @@ -15,7 +15,7 @@ Disassembly of section \.text: #... Disassembly of section \.data: -00060000 <\.data>: +00060000 .*: 60000: 00068000 .* #... Disassembly of section \.got: diff --git a/ld/testsuite/ld-scripts/expr.exp b/ld/testsuite/ld-scripts/expr.exp index 85242ed..babbf43 100644 --- a/ld/testsuite/ld-scripts/expr.exp +++ b/ld/testsuite/ld-scripts/expr.exp @@ -25,3 +25,10 @@ run_dump_test sane1 run_dump_test assign-loc run_dump_test pr14962 run_dump_test pr14962-2 + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --no-overlays --local-store 0:0" +} +run_dump_test pr18963 +set LDFLAGS $old_ldflags diff --git a/ld/testsuite/ld-scripts/pr18963.d b/ld/testsuite/ld-scripts/pr18963.d new file mode 100644 index 0000000..699db59 --- /dev/null +++ b/ld/testsuite/ld-scripts/pr18963.d @@ -0,0 +1,15 @@ +# source: data.s +# ld: -T pr18963.t +# nm: -B -n + +#... +0+70000 A D +#... +0+70000 A E +#... +0+80000 T A +#... +0+90000 T B +#... +0+a0000 D C +#pass diff --git a/ld/testsuite/ld-scripts/pr18963.t b/ld/testsuite/ld-scripts/pr18963.t new file mode 100644 index 0000000..b0cd742 --- /dev/null +++ b/ld/testsuite/ld-scripts/pr18963.t @@ -0,0 +1,25 @@ +SECTIONS +{ + . = 0x80000; + A = .; + .text : + { + _start = .; + . = 0x10000; + } + B = .; + .data : + { + . = 0x10000; + } + C = .; + .bss : + { + . = 0x10000; + } + D = A - C + B; + E = A + B - C; + /DISCARD/ : {*(*)} +} + +ASSERT(D == E, "Addition is not commutative"); |