public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: PR ld/10569: -z max-page-size may not work for linker  scripts
@ 2009-08-28  0:40 H.J. Lu
  2009-08-28  3:55 ` Alan Modra
  0 siblings, 1 reply; 15+ messages in thread
From: H.J. Lu @ 2009-08-28  0:40 UTC (permalink / raw)
  To: binutils

When a linker script change output target with

OUTPUT_FORMAT("elf32-i386")

and elf32-i386 isn't the default target, -z max-page-size won't work
correctly.

Here is a patch with 2 testcases.  OK to install?

Thanks.


H.J.
----
ld/

2009-08-27  H.J. Lu  <hongjiu.lu@intel.com>

	 PR ld/10569
	 * ldlang.c (lang_add_output_format): Call
	 bfd_emul_set_maxpagesize/bfd_emul_set_commonpagesize if
	 maximum/common page sizes are specified and output target
	 isn't the same as default target.

ld/testsuite

2009-08-27  H.J. Lu  <hongjiu.lu@intel.com>

	 PR ld/10569
	 * ld-elf/commonpage2.d: New.
	 * ld-elf/maxpage4.d: Likewise.
	 * ld-elf/maxpage4.t: Likewise.

Index: ld/testsuite/ld-elf/maxpage4.d
===================================================================
--- ld/testsuite/ld-elf/maxpage4.d	(revision 0)
+++ ld/testsuite/ld-elf/maxpage4.d	(revision 0)
@@ -0,0 +1,9 @@
+#source: maxpage1.s
+#as: --32
+#ld: -z max-page-size=0x200000 -T maxpage4.t
+#readelf: -l --wide
+#target: x86_64-*-linux*
+
+#...
+  LOAD+.*0x200000
+#pass
Index: ld/testsuite/ld-elf/maxpage4.t
===================================================================
--- ld/testsuite/ld-elf/maxpage4.t	(revision 0)
+++ ld/testsuite/ld-elf/maxpage4.t	(revision 0)
@@ -0,0 +1,9 @@
+OUTPUT_FORMAT("elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS
+{
+  .text : {*(.text)}
+  .data : {*(.data)}
+  /DISCARD/ : {*(*)}
+}
Index: ld/testsuite/ld-elf/commonpage2.d
===================================================================
--- ld/testsuite/ld-elf/commonpage2.d	(revision 0)
+++ ld/testsuite/ld-elf/commonpage2.d	(revision 0)
@@ -0,0 +1,9 @@
+#source: maxpage1.s
+#as: --32
+#ld: -z max-page-size=0x200000 -z common-page-size=0x100000 -T maxpage4.t
+#readelf: -l --wide
+#target: x86_64-*-linux*
+
+#...
+  LOAD+.*0x200000
+#pass
Index: ld/ldlang.c
===================================================================
--- ld/ldlang.c	(revision 6600)
+++ ld/ldlang.c	(working copy)
@@ -6708,6 +6708,20 @@ lang_add_output_format (const char *form
 	format = little;
 
       output_target = format;
+
+      /* If maximum/common page sizes are specified, we may need to
+         set them for OUTPUT_TARGET.  */
+      if ((config.maxpagesize != 0 || config.commonpagesize != 0)
+	  && strcmp (output_target, default_target) != 0)
+	{
+	  if (config.maxpagesize != 0)
+	    bfd_emul_set_maxpagesize (output_target,
+				      config.maxpagesize);
+
+	  if (config.commonpagesize != 0)
+	    bfd_emul_set_commonpagesize (output_target,
+					 config.commonpagesize);
+	}
     }
 }
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-09-01  0:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28  0:40 PATCH: PR ld/10569: -z max-page-size may not work for linker scripts H.J. Lu
2009-08-28  3:55 ` Alan Modra
2009-08-28  5:50   ` H.J. Lu
2009-08-28  8:01     ` H.J. Lu
2009-08-28  8:09       ` Alan Modra
2009-08-28 14:31         ` H.J. Lu
2009-08-28 14:48           ` Alan Modra
2009-08-28 15:05             ` H.J. Lu
2009-08-30 13:51               ` Alan Modra
2009-08-31  2:02                 ` H.J. Lu
2009-08-31  2:50                   ` Alan Modra
2009-08-31  6:19                     ` H.J. Lu
2009-08-31  9:09                       ` Alan Modra
2009-08-31 18:16                       ` H.J. Lu
2009-09-01  0:00                         ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).