This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Fix relro when COMMONPAGESIZE < MAXPAGESIZE
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 7 Sep 2004 15:46:04 +0200
- Subject: Re: Fix relro when COMMONPAGESIZE < MAXPAGESIZE
- References: <jebrgon0i1.fsf@sykes.suse.de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Sep 02, 2004 at 05:39:34PM +0200, Andreas Schwab wrote:
> Adjusting the relro end address during DATA_SEGMENT_ALIGN throws aways any
> previous data segment alignment, causing the resulting binary to contain a
> big hole.
Can you post readelf -WS output before and after the patch?
The big hole was certainly intended there, so that MAXPAGESIZE is properly
honored. After all, it is just diskspace (well, ld creates sparse file),
not memory.
On x86-64 I get for libc.so.6 without this patch:
[10] .plt PROGBITS 000000000001c398 01c398 0000f0 10 AX 0 0 4
[11] .text PROGBITS 000000000001c490 01c490 0e9778 00 AX 0 0 16
[12] __libc_freeres_fn PROGBITS 0000000000105c10 105c10 000911 00 AX 0 0 16
[13] __libc_thread_fre PROGBITS 0000000000106530 106530 0001ef 00 AX 0 0 16
[14] .rodata PROGBITS 0000000000106720 106720 018d58 00 A 0 0 32
[15] .interp PROGBITS 000000000011f480 11f480 00001c 00 A 0 0 16
(though am too busy with GCC now , so don't have time to play with binutils).
> 2004-09-02 Andreas Schwab <schwab@suse.de>
>
> * ldexp.c (fold_binary) [DATA_SEGMENT_ALIGN]: Apply data segment
> alignment before adjusting DATA_SEGMENT_RELRO_END.
>
> --- ld/ldexp.c 18 Aug 2004 11:08:48 +0200 1.32
> +++ ld/ldexp.c 02 Sep 2004 15:29:34 +0200
> @@ -427,6 +427,7 @@ fold_binary (etree_type *tree,
> a common page boundary. */
> bfd_vma relro;
>
> + result.value += dot & (maxpage - 1);
> relro = exp_data_seg.relro_end - exp_data_seg.base;
> result.value += -relro & (other.value - 1);
> exp_data_seg.base = result.value;
Jakub