diff options
author | Roland McGrath <roland@gnu.org> | 2012-04-03 16:01:38 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2012-04-03 16:01:38 +0000 |
commit | 5a68afcf73212d0fec1268c362dbea9f66b272a1 (patch) | |
tree | d720bac53a458cabc3bfe9799c56639624efe34b /ld/scripttempl | |
parent | a72c8f6a2934a77223ba77f972f418ec40240d1d (diff) | |
download | gdb-5a68afcf73212d0fec1268c362dbea9f66b272a1.zip gdb-5a68afcf73212d0fec1268c362dbea9f66b272a1.tar.gz gdb-5a68afcf73212d0fec1268c362dbea9f66b272a1.tar.bz2 |
bfd/
2012-04-03 Roland McGrath <mcgrathr@google.com>
* elf-nacl.c: New file.
* elf-nacl.h: New file.
* elf32-i386.c (elf_backend_modify_segment_map): Define for
bfd_elf32_i386_nacl_vec.
(elf_backend_modify_program_headers): Likewise.
* elf64-x86-64.c (elf_backend_modify_segment_map): Define for
bfd_elf64_x86_64_nacl_vec and bfd_elf32_x86_64_nacl_vec.
(elf_backend_modify_program_headers): Likewise.
* Makefile.am (BFD32_BACKENDS, BFD64_BACKENDS): Add elf-nacl.lo here.
(BFD32_BACKENDS_CFILES, BFD64_BACKENDS_CFILES): Add elf-nacl.c here.
* Makefile.in: Regenerated.
* configure.in (bfd_elf64_x86_64_nacl_vec): Add elf-nacl.o to tb here.
(bfd_elf32_x86_64_nacl_vec): Likewise.
(bfd_elf64_x86_64_vec, bfd_elf32_x86_64_vec): Likewise.
(bfd_elf64_x86_64_freebsd_vec, bfd_elf64_x86_64_sol2_vec): Likewise.
(bfd_elf64_l1om_vec, bfd_elf64_l1om_freebsd_vec): Likewise.
(bfd_elf64_k1om_vec, bfd_elf64_k1om_freebsd_vec): Likewise.
(bfd_elf32_i386_nacl_vec): Likewise.
(bfd_elf32_i386_sol2_vec, bfd_elf32_i386_freebsd_vec): Likewise.
(bfd_elf32_i386_vxworks_vec, bfd_elf32_i386_vec): Likewise.
* configure: Regenerated.
binutils/testsuite/
2012-04-03 Roland McGrath <mcgrathr@google.com>
* lib/binutils-common.exp (is_elf_format): Consider *-*-nacl* to
be ELF too.
* binutils-all/elfedit-4.d: Add "#as: --64" option.
* binutils-all/i386/i386.exp: Accept nacl targets too.
* binutils-all/x86-64/x86-64.exp: Likewise.
gas/testsuite/
2012-04-03 Roland McGrath <mcgrathr@google.com>
* gas/i386/k1om.d: Add not-target match for *-*-nacl*.
* gas/i386/l1om.d: Likewise.
ld/
2012-04-03 Roland McGrath <mcgrathr@google.com>
* configure.tgt (i[3-7]86-*-nacl*, x86_64-*-nacl*): Handle them.
* emulparams/elf_nacl.sh: New file.
* emulparams/elf_i386_nacl.sh: New file.
* emulparams/elf32_x86_64_nacl.sh: New file.
* emulparams/elf_x86_64_nacl.sh: New file.
* Makefile.am (ALL_EMULATION_SOURCES): Add eelf_i386_nacl.c here.
(ALL_64_EMULATION_SOURCES): Add eelf32_x86_64_nacl.c and
eelf_x86_64_nacl.c here.
(eelf_i386_nacl.c, eelf32_x86_64_nacl.c, eelf_x86_64_nacl.c):
New targets.
* Makefile.in: Regenerated.
* scripttempl/elf.sc: Handle SEPARATE_CODE cases.
ld/testsuite/
2012-04-03 Roland McGrath <mcgrathr@google.com>
* ld-x86-64/ilp32-4-nacl.d: New file.
* ld-x86-64/x86-64.exp: Run it.
* ld-discard/discard.exp: Accept nacl targets too.
* ld-elf/binutils.exp: Likewise.
* ld-elf/comm-data.exp: Likewise.
* ld-elf/elf.exp: Likewise.
* ld-elf/tls_common.exp: Likewise.
* ld-elfvers/vers.exp: Likewise.
* ld-elfvsb/elfvsb.exp: Likewise.
* ld-elfweak/elfweak.exp: Likewise.
* ld-gc/gc.exp: Likewise.
* ld-ifunc/binutils.exp: Likewise.
* ld-ifunc/ifunc.exp: Likewise.
* ld-linkonce/linkonce.exp:Likewise.
* ld-pie/pie.exp: Likewise.
* ld-shared/shared.exp: Likewise.
* ld-undefined/weak-undef.exp: Likewise.
* ld-unique/unique.exp: Likewise.
* ld-x86-64/dwarfreloc.exp: Likewise.
* ld-x86-64/line.exp: Likewise.
* lib/ld-lib.exp (slurp_options): Support global array
options_regsub to apply substitutions to the contents
of options lines read from the file.
* ld-i386/emit-relocs.d: Renamed to ...
* ld-i386/emit-relocs.rd: ... this.
* ld-i386/i386.exp: Accept nacl targets too.
For them, use options_regsub to replace elf_i386 with
elf_i386_nacl in run_dump_test cases; apply the same
substitution in $i386tests; replace foo.rd expectations
files with foo-nacl.rd in $i386tests.
(i386tests): Change emit-relocs.d to emit-relocs.rd here.
* ld-i386/emit-relocs-nacl.rd: New file.
* ld-i386/plt-nacl.pd: New file.
* ld-i386/plt-pic-nacl.pd: New file.
* ld-i386/tlsbin-nacl.rd: New file.
* ld-i386/tlsbindesc-nacl.rd: New file.
* ld-i386/tlsdesc-nacl.rd: New file.
* ld-i386/tlsgdesc-nacl.rd: New file.
* ld-i386/tlsnopic-nacl.rd: New file.
* ld-i386/tlspic-nacl.rd: New file.
* ld-x86-64/x86-64.exp: Accept nacl targets too.
For them, use options_regsub to replace elf_x86_64 with
elf_x86_64_nacl in run_dump_test cases; apply the same
substitution in $x86_64tests; replace foo.rd expectations
files with foo-nacl.rd in $x86_64tests.
Add explicit -melf_x86_64 to ld options in tests that need it,
in case the default emulation is x32 (as it is for x86_64-nacl).
* ld/testsuite/ld-x86-64/plt-nacl.pd: New file.
* ld/testsuite/ld-x86-64/split-by-file-nacl.rd: New file.
* ld/testsuite/ld-x86-64/tlsbin-nacl.rd: New file.
* ld/testsuite/ld-x86-64/tlsbindesc-nacl.rd: New file.
* ld/testsuite/ld-x86-64/tlsdesc-nacl.pd: New file.
* ld/testsuite/ld-x86-64/tlsdesc-nacl.rd: New file.
* ld/testsuite/ld-x86-64/tlsgdesc-nacl.rd: New file.
* ld/testsuite/ld-x86-64/tlspic-nacl.rd: New file.
* ld-i386/hidden2.d: Loosen regexps to match any file format variant,
and not to depend on exact addresses, displacements, etc. where
they are irrelevant.
* ld-i386/pcrel16.d: Likewise.
* ld-i386/pcrel16abs.d: Likewise.
* ld-i386/pr12718.d: Likewise.
* ld-i386/pr12921.d: Likewise.
* ld-i386/reloc.d: Likewise.
* ld-i386/tlsbin.dd: Likewise.
* ld-i386/tlsbin.sd: Likewise.
* ld-i386/tlsbin.td: Likewise.
* ld-i386/tlsbindesc.dd: Likewise.
* ld-i386/tlsbindesc.sd: Likewise.
* ld-i386/tlsbindesc.td: Likewise.
* ld-i386/tlsdesc.dd: Likewise.
* ld-i386/tlsdesc.sd: Likewise.
* ld-i386/tlsdesc.td: Likewise.
* ld-i386/tlsg.sd: Likewise.
* ld-i386/tlsgdesc.dd: Likewise.
* ld-i386/tlsindntpoff.dd: Likewise.
* ld-i386/tlsnopic.dd: Likewise.
* ld-i386/tlsnopic.sd: Likewise.
* ld-i386/tlspic.dd: Likewise.
* ld-i386/tlspic.sd: Likewise.
* ld-i386/tlspic.td: Likewise.
* ld-i386/tlspie2.d: Likewise.
* ld-x86-64/hidden2.d: Likewise.
* ld-x86-64/pcrel16.d: Likewise.
* ld-x86-64/pr12718.d: Likewise.
* ld-x86-64/pr12921.d: Likewise.
* ld-x86-64/protected3.d: Likewise.
* ld-x86-64/tlsbin.dd: Likewise.
* ld-x86-64/tlsbin.sd: Likewise.
* ld-x86-64/tlsbin.td: Likewise.
* ld-x86-64/tlsbindesc.dd: Likewise.
* ld-x86-64/tlsbindesc.sd: Likewise.
* ld-x86-64/tlsbindesc.td: Likewise.
* ld-x86-64/tlsdesc.dd: Likewise.
* ld-x86-64/tlsdesc.sd: Likewise.
* ld-x86-64/tlsdesc.td: Likewise.
* ld-x86-64/tlsg.sd: Likewise.
* ld-x86-64/tlsgd5.dd: Likewise.
* ld-x86-64/tlsgd6.dd: Likewise.
* ld-x86-64/tlsgdesc.dd: Likewise.
* ld-x86-64/tlspic.dd: Likewise.
* ld-x86-64/tlspic.sd: Likewise.
* ld-x86-64/tlspic.td: Likewise.
* ld-x86-64/ilp32-8.d: Match any file format variant.
Use a -Ttext and adjust expected results, to handle variant layouts.
* ld-x86-64/ilp32-9.d: Likewise.
* ld-i386/alloc.t: Remove superfluous OUTPUT_FORMAT statement.
* ld-i386/pr12627.t: Likewise.
* ld-x86-64/abs-l1om.d: Add target: constraint.
* ld-x86-64/protected2-l1om.d: Likewise.
* ld-x86-64/protected3-l1om.d: Likewise.
* ld-x86-64/ilp32-4.d: Likewise.
* ld-x86-64/plt.s: New file.
* ld-x86-64/pltlib.s: New file.
* ld-x86-64/plt.pd: New file.
* ld-x86-64/x86-64.exp (x86_64tests): Add them.
* ld-i386/plt.s: New file.
* ld-i386/pltlib.s: New file.
* ld-i386/plt.pd: New file.
* ld-i386/plt-pic.s: New file.
* ld-i386/plt-pic.pd: New file.
* ld-i386/i386.exp (i386tests): Add them.
Diffstat (limited to 'ld/scripttempl')
-rw-r--r-- | ld/scripttempl/elf.sc | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 7994b5f..5796b0a 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -40,7 +40,7 @@ # NO_RELA_RELOCS - Don't include .rela.* sections in script # NON_ALLOC_DYN - Place dynamic sections after data segment. # TEXT_DYNAMIC - .dynamic in text segment, not data segment. -# EMBEDDED - whether this is for an embedded system. +# EMBEDDED - whether this is for an embedded system. # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set # start address of shared library. # INPUT_FILES - INPUT command of files to always include @@ -53,6 +53,9 @@ # OTHER_SYMBOLS - symbols to place right at the end of the script. # ETEXT_NAME - name of a symbol for the end of the text section, # normally etext. +# SEPARATE_CODE - if set, .text and similar sections containing +# actual machine instructions must be in wholly disjoint +# pages from any other data, including headers # SEPARATE_GOTPLT - if set, .got.plt should be separate output section, # so that .got can be in the RELRO area. It should be set to # the number of bytes in the beginning of .got.plt which can be @@ -170,7 +173,7 @@ if test -z "${NO_SMALL_DATA}"; then SDATA="/* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ - .${SDATA_NAME} ${RELOCATING-0} : + .${SDATA_NAME} ${RELOCATING-0} : { ${RELOCATING+${SDATA_START_SYMBOLS}} ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} @@ -255,7 +258,7 @@ FINI_ARRAY=".fini_array ${RELOCATING-0} : ${DTORS_IN_FINI_ARRAY} ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} }" -CTOR=".ctors ${CONSTRUCTING-0} : +CTOR=".ctors ${CONSTRUCTING-0} : { ${CONSTRUCTING+${CTOR_START}} /* gcc uses crtbegin.o to find the start of @@ -300,9 +303,15 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +if [ -z "$SEPARATE_CODE" ]; then + SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" +else + SIZEOF_HEADERS_CODE= +fi + # if this is for an embedded system, don't add SIZEOF_HEADERS. if [ -z "$EMBEDDED" ]; then - test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" else test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" fi @@ -325,11 +334,19 @@ SECTIONS { /* Read-only sections, merged into text segment: */ ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} - ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} - ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} +EOF + +emit_early_ro() +{ + cat <<EOF ${INITIAL_READONLY_SECTIONS} .note.gnu.build-id : { *(.note.gnu.build-id) } EOF +} + +test -n "${SEPARATE_CODE}" || emit_early_ro test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= @@ -424,7 +441,8 @@ cat >> ldscripts/dyntmp.$$ <<EOF ${OTHER_PLT_RELOC_SECTIONS} EOF -if test -z "${NON_ALLOC_DYN}"; then +emit_dyn() +{ if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then cat ldscripts/dyntmp.$$ else @@ -436,11 +454,13 @@ if test -z "${NON_ALLOC_DYN}"; then fi fi rm -f ldscripts/dyntmp.$$ -fi +} + +test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn cat <<EOF - .init ${RELOCATING-0} : - { + .init ${RELOCATING-0} : + { ${RELOCATING+${INIT_START}} KEEP (*(.init)) ${RELOCATING+${INIT_END}} @@ -469,6 +489,21 @@ cat <<EOF ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} +EOF + +if test -n "${SEPARATE_CODE}"; then + cat <<EOF + /* Adjust the address for the rodata segment. We want to adjust up to + the same address within the page on the next page up. */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}} +EOF + emit_early_ro + emit_dyn +fi + +cat <<EOF ${WRITABLE_RODATA-${RODATA}} .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } ${CREATE_SHLIB-${SDATA2}} @@ -565,19 +600,7 @@ cat <<EOF ${RELOCATING+${DATA_SEGMENT_END}} EOF -if test -n "${NON_ALLOC_DYN}"; then - if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then - cat ldscripts/dyntmp.$$ - else - if test -z "${NO_REL_RELOCS}"; then - sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ - fi - if test -z "${NO_RELA_RELOCS}"; then - sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ - fi - fi - rm -f ldscripts/dyntmp.$$ -fi +test -z "${NON_ALLOC_DYN}" || emit_dyn cat <<EOF /* Stabs debugging sections. */ |