This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fix -z max-page-size
On Wed, Jan 17, 2007 at 09:29:41AM -0800, H. J. Lu wrote:
>
> I'd like a consistent solution. That is all codes in linker should
> get the same maximum/common pagesize at any given time. Your change
> may make fold_name to get a different maximum/common pagesize than
> the rest of program.
>
Here is my patch for this issue.
H.J.
---
ld/
2007-01-17 Jakub Jelinek <jakub@redhat.com>
H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (handle_option): Make sure -z max-page-size
or -z common-page-size argument is a power of 2. Call
bfd_emul_set_maxpagesize and bfd_emul_set_commonpagesize.
2007-01-17 H.J. Lu <hongjiu.lu@intel.com>
* ldmain.c (main): Don't call bfd_emul_set_maxpagesize nor
bfd_emul_set_commonpagesize.
ld/testsuite/
2007-01-17 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/maxpage3.t: New file.
* ld-elf/maxpage3a.d: Likewise.
* ld-elf/maxpage3b.d: Likewise.
* ld-elf/maxpage3c.d: Likewise.
--- ld/emultempl/elf32.em.pagesize 2007-01-17 12:14:44.000000000 -0800
+++ ld/emultempl/elf32.em 2007-01-17 19:42:14.000000000 -0800
@@ -1923,17 +1923,23 @@ cat >>e${EMULATION_NAME}.c <<EOF
char *end;
config.maxpagesize = strtoul (optarg + 14, &end, 0);
- if (*end)
+ if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
einfo (_("%P%F: invalid maxium page size \`%s'\n"),
optarg + 14);
+ ASSERT (default_target != NULL);
+ bfd_emul_set_maxpagesize (default_target, config.maxpagesize);
}
else if (CONST_STRNEQ (optarg, "common-page-size="))
{
char *end;
config.commonpagesize = strtoul (optarg + 17, &end, 0);
- if (*end)
+ if (*end
+ || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
einfo (_("%P%F: invalid common page size \`%s'\n"),
optarg + 17);
+ ASSERT (default_target != NULL);
+ bfd_emul_set_commonpagesize (default_target,
+ config.commonpagesize);
}
/* What about the other Solaris -z options? FIXME. */
break;
--- ld/ldmain.c.pagesize 2007-01-17 12:14:44.000000000 -0800
+++ ld/ldmain.c 2007-01-17 19:35:52.000000000 -0800
@@ -346,13 +346,6 @@ main (int argc, char **argv)
if (config.hash_table_size != 0)
bfd_hash_set_default_size (config.hash_table_size);
- if (config.maxpagesize != 0)
- bfd_emul_set_maxpagesize (default_target, config.maxpagesize);
-
- if (config.commonpagesize != 0)
- bfd_emul_set_commonpagesize (default_target,
- config.commonpagesize);
-
ldemul_set_symbols ();
if (link_info.relocatable)
--- ld/testsuite/ld-elf/maxpage3.t.pagesize 2007-01-17 19:47:35.000000000 -0800
+++ ld/testsuite/ld-elf/maxpage3.t 2007-01-17 17:39:19.000000000 -0800
@@ -0,0 +1,7 @@
+SECTIONS
+{
+ .text : {*(.text)}
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
+ .data : {*(.data)}
+ /DISCARD/ : {*(*)}
+}
--- ld/testsuite/ld-elf/maxpage3a.d.pagesize 2007-01-17 19:47:35.000000000 -0800
+++ ld/testsuite/ld-elf/maxpage3a.d 2007-01-17 19:44:22.000000000 -0800
@@ -0,0 +1,11 @@
+#source: maxpage1.s
+#ld: -z max-page-size=0x10000000 -T maxpage3.t
+#readelf: -lS --wide
+#target: *-*-linux*
+
+#...
+ \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*10000000[ \t]+[ \t0-9a-f]+WA?.*
+#...
+ LOAD+.*0x10000000
+ LOAD+.*0x10000000
+#pass
--- ld/testsuite/ld-elf/maxpage3b.d.pagesize 2007-01-17 19:47:35.000000000 -0800
+++ ld/testsuite/ld-elf/maxpage3b.d 2007-01-17 19:44:30.000000000 -0800
@@ -0,0 +1,10 @@
+#source: maxpage1.s
+#ld: -T maxpage3.t -z max-page-size=0x10000000
+#readelf: -lS --wide
+#target: x86_64-*-linux*
+
+#...
+ \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*200000[ \t]+[ \t0-9a-f]+WA?.*
+#...
+ LOAD+.*0x10000000
+#pass
--- ld/testsuite/ld-elf/maxpage3c.d.pagesize 2007-01-17 19:47:35.000000000 -0800
+++ ld/testsuite/ld-elf/maxpage3c.d 2007-01-17 19:46:54.000000000 -0800
@@ -0,0 +1,12 @@
+#source: maxpage1.s
+#as: --32
+#ld: -m elf_i386 -z max-page-size=0x10000000 -T maxpage3.t
+#readelf: -lS --wide
+#target: x86_64-*-linux*
+
+#...
+ \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t]+0*10000000[ \t]+[ \t0-9a-f]+WA?.*
+#...
+ LOAD+.*0x10000000
+ LOAD+.*0x10000000
+#pass