[PATCH 4/6] ld: adjust ld-scripts/map-address.*

Jan Beulich jbeulich@suse.com
Tue Mar 2 09:49:02 GMT 2021


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.

ld/
2021-02-XX  Jan Beulich  <jbeulich@suse.com>

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

--- a/ld/testsuite/ld-scripts/map-address.exp
+++ b/ld/testsuite/ld-scripts/map-address.exp
@@ -26,9 +26,15 @@ if {![ld_assemble $as $srcdir/$subdir/si
     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
@@ -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
@@ -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
@@ -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
--- a/ld/testsuite/ld-scripts/map-address.t
+++ b/ld/testsuite/ld-scripts/map-address.t
@@ -8,4 +8,7 @@ SECTIONS
   bar = .;
   . = ALIGN (4);
   frob = .;
+
+  . = 0x10000;
+  .text : { *(.text) }
 }



More information about the Binutils mailing list