Bug 18176 - Large file size due to padding for PT_GNU_RELRO segment
Summary: Large file size due to padding for PT_GNU_RELRO segment
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-29 03:17 UTC by H.J. Lu
Modified: 2022-02-13 03:35 UTC (History)
0 users

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Last reconfirmed:


Attachments
A testcase (1.55 KB, application/x-xz)
2015-03-29 03:17 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-03-29 03:17:41 UTC
Created attachment 8215 [details]
A testcase

When a padding in file is used to align PT_GNU_RELRO segment, the maximum
padding size is maximum page size minus 1, which may lead to large file
size:

[hjl@gnu-tools-1 relro]$ make
as   -o x.o x.s
./ld -z relro -T ld.t -z max-page-size=0x200000 -z common-page-size=0x1000 -shared -o x.so x.o
ls -l x.so
-rwxrwxr-x 1 hjl hjl 2419808 Mar 28 20:17 x.so
[hjl@gnu-tools-1 relro]$
Comment 1 Sourceware Commits 2015-04-01 11:25:49 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=875b5b9d147d37c99a189aa95354f9bebdd64ef5

commit 875b5b9d147d37c99a189aa95354f9bebdd64ef5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Apr 1 04:24:05 2015 -0700

    Add a testcase for PR ld/18176
    
    	PR ld/18176
    	* ld-x86-64/pr18176.d: New file.
    	* ld-x86-64/pr18176.s: Likewise.
    	* ld-x86-64/pr18176.t: Likewise.
    	* ld-x86-64/x86-64.exp: Run pr18176.
Comment 3 Sourceware Commits 2015-04-07 13:53:21 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0fad6e4b94e754e26e904bab074bf6c94d825711

commit 0fad6e4b94e754e26e904bab074bf6c94d825711
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Apr 7 10:39:59 2015 +0930

    Cast shift expression
    
    	PR ld/18176
    	* ldlang.c (lang_size_sections): Cast shift expression.
Comment 4 Sourceware Commits 2022-02-13 03:35:36 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=31b4d3a16f200bf04db8439a63b72bba7af4e1be

commit 31b4d3a16f200bf04db8439a63b72bba7af4e1be
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Feb 3 08:57:47 2022 +1030

    PR28824, relro security issues, x86 keep COMMONPAGESIZE relro
    
    x86 treats MAXPAGESIZE as a memory optimisation parameter, actual
    hardware paging is always COMMPAGESIZE of 4k.  Use COMMONPAGESIZE for
    the end of the relro segment alignment.
    
    The previous patch regresses pr18176, increasing the testcase file
    size from 322208 to 2099872 bytes.  Fixing this on x86 will require
    introducing a gap after the end of the relro segment (of up to
    relropagesize-1 bytes).
    
            PR 28824
            PR 18176
            * ld.h (ld_config_type): Add relro_use_commonpagesize field.
            * ldexp.c (fold_segment_align): Set relropagesize depending on
            relro_use_commonpagesize.
            * emultempl/elf-x86.em (elf_x86_create_output_section_statements):
            Set relro_use_commonpagesize.
            * testsuite/ld-x86-64/pr18176.d: xfail.