RFC: x86: Enable -z separate-code by default

H.J. Lu hjl.tools@gmail.com
Mon Feb 19 16:39:00 GMT 2018


On Mon, Feb 19, 2018 at 7:53 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Mon, 19 Feb 2018, H.J. Lu wrote:
>
>> This patch enables -z separate-code by default for x86.  To reduce
>> x86-64 binary size, set ELF_MAXPAGESIZE to 4KB.
>
> Meh :-(  Have you done any performance measurements on, say, SPECcpu?

We will.

>> Should I add an ld configure option, --enable-separate-code, instead?
>
> Yes, definitely.  For old distros at least I definitely want to retain old
> behaviour by default and a configure switch would make that easier.

Will do.

H.J.
>
> Ciao,
> Michael.
>
>>
>>
>> H.J.
>> ---
>> bfd/
>>       * elf64-x86-64.c (ELF_MAXPAGESIZE): Set to 0x1000.
>>
>> ld/
>>
>>       * emulparams/elf32_x86_64.sh (DEFAULT_SEPARATE_CODE): New.
>>       * emulparams/elf_i386.sh (DEFAULT_SEPARATE_CODE): Likewise.
>>       * emulparams/elf_x86_64.sh (DEFAULT_SEPARATE_CODE): Likewise.
>>       * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
>>       link_info.separate_code to TRUE if ${DEFAULT_SEPARATE_CODE} is
>>       yes.
>> ---
>>  bfd/elf64-x86-64.c            | 4 ++--
>>  ld/emulparams/elf32_x86_64.sh | 1 +
>>  ld/emulparams/elf_i386.sh     | 1 +
>>  ld/emulparams/elf_x86_64.sh   | 1 +
>>  ld/emultempl/elf32.em         | 1 +
>>  5 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
>> index 00ed5d17a5..51c301bae6 100644
>> --- a/bfd/elf64-x86-64.c
>> +++ b/bfd/elf64-x86-64.c
>> @@ -4934,7 +4934,7 @@ elf_x86_64_special_sections[]=
>>  #define ELF_ARCH                         bfd_arch_i386
>>  #define ELF_TARGET_ID                            X86_64_ELF_DATA
>>  #define ELF_MACHINE_CODE                 EM_X86_64
>> -#define ELF_MAXPAGESIZE                          0x200000
>> +#define ELF_MAXPAGESIZE                          0x1000
>>  #define ELF_MINPAGESIZE                          0x1000
>>  #define ELF_COMMONPAGESIZE               0x1000
>>
>> @@ -5327,7 +5327,7 @@ elf64_l1om_elf_object_p (bfd *abfd)
>>  #undef       ELF_MAXPAGESIZE
>>  #undef       ELF_MINPAGESIZE
>>  #undef       ELF_COMMONPAGESIZE
>> -#define ELF_MAXPAGESIZE                      0x200000
>> +#define ELF_MAXPAGESIZE                      0x1000
>>  #define ELF_MINPAGESIZE                      0x1000
>>  #define ELF_COMMONPAGESIZE           0x1000
>>  #undef       elf_backend_plt_alignment
>> diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
>> index 9ce6533bd9..f8e004829d 100644
>> --- a/ld/emulparams/elf32_x86_64.sh
>> +++ b/ld/emulparams/elf32_x86_64.sh
>> @@ -14,6 +14,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
>>  ARCH="i386:x64-32"
>>  MACHINE=
>>  TEMPLATE_NAME=elf32
>> +DEFAULT_SEPARATE_CODE=yes
>>  GENERATE_SHLIB_SCRIPT=yes
>>  GENERATE_PIE_SCRIPT=yes
>>  NO_SMALL_DATA=yes
>> diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
>> index 2cef106e3d..6c451aac8a 100644
>> --- a/ld/emulparams/elf_i386.sh
>> +++ b/ld/emulparams/elf_i386.sh
>> @@ -12,6 +12,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
>>  ARCH=i386
>>  MACHINE=
>>  TEMPLATE_NAME=elf32
>> +DEFAULT_SEPARATE_CODE=yes
>>  GENERATE_SHLIB_SCRIPT=yes
>>  GENERATE_PIE_SCRIPT=yes
>>  NO_SMALL_DATA=yes
>> diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
>> index d8c6e54894..8e18d81bdf 100644
>> --- a/ld/emulparams/elf_x86_64.sh
>> +++ b/ld/emulparams/elf_x86_64.sh
>> @@ -14,6 +14,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
>>  ARCH="i386:x86-64"
>>  MACHINE=
>>  TEMPLATE_NAME=elf32
>> +DEFAULT_SEPARATE_CODE=yes
>>  GENERATE_SHLIB_SCRIPT=yes
>>  GENERATE_PIE_SCRIPT=yes
>>  NO_SMALL_DATA=yes
>> diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
>> index c0925fc9b9..1325b4742f 100644
>> --- a/ld/emultempl/elf32.em
>> +++ b/ld/emultempl/elf32.em
>> @@ -104,6 +104,7 @@ gld${EMULATION_NAME}_before_parse (void)
>>    config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
>>    config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
>>    `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
>> +  link_info.separate_code = `if test "x${DEFAULT_SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
>>    link_info.check_relocs_after_open_input = TRUE;
>>    link_info.relro = DEFAULT_LD_Z_RELRO;
>>  }
>>



-- 
H.J.



More information about the Binutils mailing list