Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
ld: adjust ld-scripts/map-address.*
Browse files Browse the repository at this point in the history
Without setting an image base address and without naming at least .text,
this test produces entirely bogus PE output. To be honest, even the ELF
output looks odd: .text gets placed at 0x10204, and both foo and bar get
associated with .text despite living below its start address.

Since neither image base nor .text placement are the subject of this
test, specify .text placement explicitly and in the PE case force the
image base to zero.
  • Loading branch information
jbeulich committed Mar 4, 2021
1 parent 6b5465b commit d4e5db4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ld/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2021-03-04 Jan Beulich <[email protected]>

* testsuite/ld-scripts/map-address.exp: Set image base to zero
for PE/COFF.
* testsuite/ld-scripts/map-address.t: Place .text.

2021-03-04 Jan Beulich <[email protected]>

* ldexp.c (ldexp_is_final_sym_absolute): New.
Expand Down
14 changes: 10 additions & 4 deletions ld/testsuite/ld-scripts/map-address.exp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ if {![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/map-address.o]} {
return
}

if { [is_pecoff_format] } then {
set IMAGE_BASE "--image-base 0"
} else {
set IMAGE_BASE ""
}

if {![ld_link $ld tmpdir/map-address \
"$LDFLAGS -T $srcdir/$subdir/map-address.t \
tmpdir/map-address.o \
$IMAGE_BASE tmpdir/map-address.o \
-Map tmpdir/map-address.map"]} {
fail $testname
return
Expand All @@ -51,7 +57,7 @@ set testname "map to directory"

if {![ld_link $ld tmpdir/map-address \
"$LDFLAGS -T $srcdir/$subdir/map-address.t \
tmpdir/map-address.o \
$IMAGE_BASE tmpdir/map-address.o \
-Map tmpdir --output fred"]} {
fail $testname
return
Expand All @@ -74,7 +80,7 @@ set testname "map to % directory"

if {![ld_link $ld tmpdir/map-address \
"$LDFLAGS -T $srcdir/$subdir/map-address.t \
tmpdir/map-address.o \
$IMAGE_BASE tmpdir/map-address.o \
-Map=tmpdir/% --output fred"]} {
fail $testname
return
Expand All @@ -97,7 +103,7 @@ set testname "map to %.foo directory"

if {![ld_link $ld tmpdir/map-address \
"$LDFLAGS -T $srcdir/$subdir/map-address.t \
tmpdir/map-address.o \
$IMAGE_BASE tmpdir/map-address.o \
-Map=tmpdir/%.foo --output fred"]} {
fail $testname
return
Expand Down
3 changes: 3 additions & 0 deletions ld/testsuite/ld-scripts/map-address.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ SECTIONS
bar = .;
. = ALIGN (4);
frob = .;

. = 0x10000;
.text : { *(.text) }
}

0 comments on commit d4e5db4

Please sign in to comment.