From: "H.J. Lu" <hjl.tools@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, binutils <binutils@sources.redhat.com>
Subject: Re: PATCH: PR ld/10569: -z max-page-size may not work for linker scripts
Date: Mon, 31 Aug 2009 18:16:00 -0000 [thread overview]
Message-ID: <6dc9ffc80908311042l486a5426sf38f23459de60340@mail.gmail.com> (raw)
In-Reply-To: <6dc9ffc80908301902y59e745f8jff2ec9f88ea07ac1@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]
On Sun, Aug 30, 2009 at 7:02 PM, H.J. Lu<hjl.tools@gmail.com> wrote:
> On Sun, Aug 30, 2009 at 6:47 PM, Alan Modra<amodra@bigpond.net.au> wrote:
>> On Sun, Aug 30, 2009 at 11:42:20AM -0700, H.J. Lu wrote:
>>> What should happen case where
>>>
>>> 1. No -z page size command line option is given.
>>> 2. Output target is ELF and whose page size is different from default target.
>>>
>>> Your checkin changes the output page size to the page size of the default
>>> target.
>>
>> Yes, I treat "--oformat other_elf" just the same as "--oformat srec".
>> I don't really have a strong opinion as to what should be done in
>> this case.
>>
>
> It can also happen with
>
> OUTPUT_FORMAT("elf32-i386")
> OUTPUT_ARCH(i386)
>
> in linker script and all input files are elf32-i386. I won't expect
> the page size
> won't be 4KB. This is a regression.
>
Here is a patch to call bfd_emul_set_maxpagesize and
bfd_emul_set_commonpagesize only if they. OK to
install?
Thanks.
--
H.J.
---
2009-08-31 H.J. Lu <hongjiu.lu@intel.com>
* ld.h (ld_config_type): Add maxpagesize_set and
commonpagesize_set.
* ldemul.c (set_output_arch_default): Call
bfd_emul_set_maxpagesize/bfd_emul_set_commonpagesize only
if config.maxpagesize_set/config.commonpagesize_set is TRUE.
* ldmain.c (main): Initialize config.maxpagesize_set and
config.commonpagesize_set to FALSE.
* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Set
config.maxpagesize_set/config.commonpagesize_set to TRUE when
config.maxpagesize/config.commonpagesize is set.
[-- Attachment #2: ld-page-size-3.patch --]
[-- Type: text/plain, Size: 3098 bytes --]
2009-08-31 H.J. Lu <hongjiu.lu@intel.com>
* ld.h (ld_config_type): Add maxpagesize_set and
commonpagesize_set.
* ldemul.c (set_output_arch_default): Call
bfd_emul_set_commonpagesize/bfd_emul_set_commonpagesize only
if config.maxpagesize_set/config.commonpagesize_set is TRUE.
* ldmain.c (main): Initialize config.maxpagesize_set and
config.commonpagesize_set to FALSE.
* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Set
config.maxpagesize_set/config.commonpagesize_set to TRUE when
config.maxpagesize/config.commonpagesize is set.
Index: ld/emultempl/elf32.em
===================================================================
--- ld/emultempl/elf32.em (revision 6667)
+++ ld/emultempl/elf32.em (working copy)
@@ -2178,6 +2178,7 @@ fragment <<EOF
if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
einfo (_("%P%F: invalid maxium page size \`%s'\n"),
optarg + 14);
+ config.maxpagesize_set = TRUE;
}
else if (CONST_STRNEQ (optarg, "common-page-size="))
{
@@ -2187,6 +2188,7 @@ fragment <<EOF
|| (config.commonpagesize & (config.commonpagesize - 1)) != 0)
einfo (_("%P%F: invalid common page size \`%s'\n"),
optarg + 17);
+ config.commonpagesize_set = TRUE;
}
/* What about the other Solaris -z options? FIXME. */
break;
Index: ld/ld.h
===================================================================
--- ld/ld.h (revision 6665)
+++ ld/ld.h (working copy)
@@ -280,8 +280,14 @@ typedef struct {
/* The maximum page size for ELF. */
bfd_vma maxpagesize;
+ /* The maximum page size for ELF is set. */
+ bfd_boolean maxpagesize_set;
+
/* The common page size for ELF. */
bfd_vma commonpagesize;
+
+ /* The common page size for ELF is set. */
+ bfd_boolean commonpagesize_set;
} ld_config_type;
extern ld_config_type config;
Index: ld/ldmain.c
===================================================================
--- ld/ldmain.c (revision 6667)
+++ ld/ldmain.c (working copy)
@@ -281,7 +281,9 @@ main (int argc, char **argv)
ldemul_choose_mode (emulation);
default_target = ldemul_choose_target (argc, argv);
config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+ config.maxpagesize_set = FALSE;
config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+ config.commonpagesize_set = FALSE;
lang_init ();
ldemul_before_parse ();
lang_has_input_file = FALSE;
Index: ld/ldemul.c
===================================================================
--- ld/ldemul.c (revision 6667)
+++ ld/ldemul.c (working copy)
@@ -229,8 +229,10 @@ set_output_arch_default (void)
bfd_set_arch_mach (link_info.output_bfd,
ldfile_output_architecture, ldfile_output_machine);
- bfd_emul_set_maxpagesize (output_target, config.maxpagesize);
- bfd_emul_set_commonpagesize (output_target, config.commonpagesize);
+ if (config.maxpagesize_set)
+ bfd_emul_set_maxpagesize (output_target, config.maxpagesize);
+ if (config.commonpagesize_set)
+ bfd_emul_set_commonpagesize (output_target, config.commonpagesize);
}
void
next prev parent reply other threads:[~2009-08-31 17:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 0:40 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 [this message]
2009-09-01 0:00 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6dc9ffc80908311042l486a5426sf38f23459de60340@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=binutils@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).