This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC PATCH] Little hardening DSOs/executables against exploits (take 2)


On Wed, Jan 14, 2004 at 09:09:00AM +0100, Jakub Jelinek wrote:
> The logic could be written as (on ppc32 example (BTW, shouldn't elf32ppc.sh
> define COMMONPAGESIZE=0x1000 ?)).

Yes.  Done.

	* emulparams/elf32ppc.sh (COMMONPAGESIZE): Define.

Index: ld/emulparams/elf32ppc.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32ppc.sh,v
retrieving revision 1.12
diff -u -p -r1.12 elf32ppc.sh
--- ld/emulparams/elf32ppc.sh	30 May 2003 15:50:11 -0000	1.12
+++ ld/emulparams/elf32ppc.sh	15 Jan 2004 12:24:34 -0000
@@ -9,6 +9,7 @@ SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-powerpc"
 TEXT_START_ADDR=0x01800000
 MAXPAGESIZE=0x10000
+COMMONPAGESIZE=0x1000
 ARCH=powerpc:common
 MACHINE=
 BSS_PLT=


>   .jcr            : { KEEP (*(.jcr)) }
>   .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
>   .dynamic        : { *(.dynamic) }
>   .fixup          : ONLY_IF (SIZE (.sbss) < 1024 || THIS_SEGMENT_SIZE <= 32768) { *(.fixup) }
>   .got1           : ONLY_IF (SIZE (.sbss) < 1024 || THIS_SEGMENT_SIZE <= 32768) { *(.got1) }
>   .got2           : ONLY_IF (SIZE (.sbss) < 1024 || THIS_SEGMENT_SIZE <= 32768) { *(.got2) }

The above three sections can always go here.  No need for anything fancy
as they're not accessed via r13.

.sdata2 and .sbss2 are EABI only, and in the non-shared lib case are
accessed via r2.  In that case, you shouldn't include them in any
calculations involving the size of data accessed via r13.  When building
shared libs they _are_ accessed via r13, the same as .got, .sdata and
.sbss.  Another weird thing about .sdata2 is that the EABI says
  "The special section .sdata2 is intended to hold initialized read-only
  small data that contribute to the program memory image.  The section
  can, however, be used to hold writable data."
It seems to me that the current linker script puts them in the wrong
place..

Incidentally, instead of inventing new "ONLY_IF" and "THIS_SEGMENT_SIZE"
magic, can't you just use

. = some_condition_on_section_sizes ? . : DATA_SEGMENT_RELRO_END (.);
.got { ... };
. = some_condition_on_section_sizes ? DATA_SEGMENT_RELRO_END (.) : .;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]