diff options
author | Alan Modra <amodra@gmail.com> | 2018-04-14 16:23:56 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-04-14 17:56:40 +0930 |
commit | 702d167134149f420ea3bcbc194d63a2653a0c27 (patch) | |
tree | 3039514093375d874d15ac74aed9cfc5d1a0ecfb /ld/ldemul.c | |
parent | 03aa968462e0345b2d846ca240b8c723d713761a (diff) | |
download | binutils-702d167134149f420ea3bcbc194d63a2653a0c27.zip binutils-702d167134149f420ea3bcbc194d63a2653a0c27.tar.gz binutils-702d167134149f420ea3bcbc194d63a2653a0c27.tar.bz2 |
powerpc common-page-size
max-page-size only matters for demand paged executables or shared
libraries, and the ideal size is the largest value used by your
operating system. Values larger than necessary just waste file space
and memory. common-page-size also affects file and memory size,
trading a possible small increase in file size for a decrease in
memory size when the operating system is using a common-page-size
page. With a powerpc max-page-size of 64k and common-page-size of 4k
many executables will use no more memory pages when the system page
size is 4k than an executable linked with -z max-page-size=0x1000,
yet will still run on a system using 64k pages. However, when running
on a system using 64k pages relro protection will not be completely
effective.
Due to the relro problem, powerpc binutils has been using a default
common-page-size of 64k since 2014-12-18 (git commit 04c6a44c7),
leading to complaints about increased file and memory sizes. People
not using relro do have a valid reason to complain..
So this patch introduces an extra back-end value to use as the default
for common-page-size when generating relro executables, and enables
the support for powerpc. Non relro executables will now be generated
with a default common-page-size of 4k.
bfd/
* elf-bfd.h (struct elf_backend_data): Add relropagesize.
* elfxx-target.h (ELF_RELROPAGESIZE): Provide default and
sanity test.
(elfNN_bed): Init relropagesize.
* bfd.c (bfd_emul_get_commonpagesize): Add boolean param to
select relropagesize.
* elf32-ppc.c (ELF_COMMONPAGESIZE): Define as 0x1000.
(ELF_RELROPAGESIZE): Define as ELF_MAXPAGESIZE.
(ELF_MINPAGESIZE): Don't define.
* elf64-ppc.c (ELF_COMMONPAGESIZE): Define as 0x1000.
(ELF_RELROPAGESIZE): Define as ELF_MAXPAGESIZE.
* bfd-in2.h: Regenerate.
ld/
* ldmain.c (main): Move config.maxpagesize and
config.commonpagesize initialization to..
* ldemul.c (after_parse_default): ..here.
* testsuite/ld-powerpc/ppc476-shared.d: Pass -z common-page-size.
* testsuite/ld-powerpc/ppc476-shared2.d: Likewise.
Diffstat (limited to 'ld/ldemul.c')
-rw-r--r-- | ld/ldemul.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ld/ldemul.c b/ld/ldemul.c index 6e5b0de..cd6743d 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -225,6 +225,11 @@ after_parse_default (void) if (!is_vma) ldlang_add_undef (entry_symbol.name, entry_from_cmdline); } + if (config.maxpagesize == 0) + config.maxpagesize = bfd_emul_get_maxpagesize (default_target); + if (config.commonpagesize == 0) + config.commonpagesize = bfd_emul_get_commonpagesize (default_target, + link_info.relro); } void |