PATCH: PR ld/11628: "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr

H.J. Lu hjl.tools@gmail.com
Tue May 25 19:19:00 GMT 2010


On Mon, May 24, 2010 at 1:54 PM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hongjiu.lu@intel.com> writes:
>
>> ORG in "ld -Ttext-segment=ORG" should be multiple of maximum page size.
>> This patch issues an error if ORG isn't multiple of maximum page size.
>> OK to install?
>
> If -n or -N is used there should not be such a requirement.
>
> Ian
>

How about this patch?

-- 
H.J.
---

ld/

2010-05-25  H.J. Lu  <hongjiu.lu@intel.com>

 	PR ld/11628
	* ldexp.c (fold_binary): Warn if value of SEGMENT_START isn't
	multiple of maximum page size.

ld/testsuite/

2010-05-25  H.J. Lu  <hongjiu.lu@intel.com>

 	PR ld/11628
	* ld-elf/textaddr3.d: New.
	* ld-elf/textaddr4.d: Likewise.
	* ld-elf/textaddr5.d: Likewise.
	* ld-elf/textaddr6.d: Likewise.
	* ld-elf/textaddr7.d: Likewise.
-------------- next part --------------
ld/

2010-05-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/11628
	* ldexp.c (fold_binary): Warn if value of SEGMENT_START isn't
	multiple of maximum page size.

ld/testsuite/

2010-05-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/11628
	* ld-elf/textaddr3.d: New.
	* ld-elf/textaddr4.d: Likewise.
	* ld-elf/textaddr5.d: Likewise.
	* ld-elf/textaddr6.d: Likewise.
	* ld-elf/textaddr7.d: Likewise.

diff --git a/ld/ldexp.c b/ld/ldexp.c
index 34d9eab..c0ca818 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -299,6 +299,11 @@ fold_binary (etree_type *tree)
       for (seg = segments; seg; seg = seg->next) 
 	if (strcmp (seg->name, segment_name) == 0)
 	  {
+	    if (!seg->used
+		&& config.magic_demand_paged
+		&& (seg->value % config.maxpagesize) != 0)
+	      einfo (_("%P: warning: address of `%s' isn't multiple of maximum page size\n"),
+		     segment_name);
 	    seg->used = TRUE;
 	    expld.result.value = seg->value;
 	    expld.result.str = NULL;
--- /dev/null	2010-05-24 09:41:04.580007186 -0700
+++ binutils/ld/testsuite/ld-elf/textaddr3.d	2010-05-25 12:12:41.871442026 -0700
@@ -0,0 +1,4 @@
+#source: maxpage1.s
+#ld: -Ttext-segment 0x10000 -z max-page-size=0x200000
+#target: *-*-linux-gnu
+#warning: .*address of `text-segment' isn't multiple of maximum page size
--- /dev/null	2010-05-24 09:41:04.580007186 -0700
+++ binutils/ld/testsuite/ld-elf/textaddr4.d	2010-05-24 11:14:22.263600575 -0700
@@ -0,0 +1,8 @@
+#source: maxpage1.s
+#ld: -z max-page-size=0x10000 -Ttext-segment 0x10000
+#readelf: -l --wide
+#target: *-*-linux-gnu
+
+#...
+  LOAD +0x0+ 0x0*10000 0x0*10000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x10000
+#pass
--- /dev/null	2010-05-24 09:41:04.580007186 -0700
+++ binutils/ld/testsuite/ld-elf/textaddr5.d	2010-05-25 12:10:38.095444527 -0700
@@ -0,0 +1,4 @@
+#source: maxpage1.s
+#ld: -shared -z max-page-size=0x200000 -Ttext-segment 0x10000
+#target: *-*-linux-gnu
+#warning: .*address of `text-segment' isn't multiple of maximum page size
--- /dev/null	2010-05-24 09:41:04.580007186 -0700
+++ binutils/ld/testsuite/ld-elf/textaddr6.d	2010-05-24 11:14:45.030440124 -0700
@@ -0,0 +1,8 @@
+#source: maxpage1.s
+#ld: -shared -z max-page-size=0x10000 -Ttext-segment 0x10000
+#readelf: -l --wide
+#target: *-*-linux-gnu
+
+#...
+  LOAD +0x0+ 0x0*10000 0x0*10000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x10000
+#pass
--- /dev/null	2010-05-24 09:41:04.580007186 -0700
+++ binutils/ld/testsuite/ld-elf/textaddr7.d	2010-05-25 12:13:50.486445531 -0700
@@ -0,0 +1,8 @@
+#source: maxpage1.s
+#ld: -n -z max-page-size=0x200000 -Ttext-segment 0x10000
+#readelf: -l --wide
+#target: *-*-linux-gnu
+
+#...
+  LOAD .*
+#pass


More information about the Binutils mailing list