diff options
author | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2016-08-26 10:59:26 +0100 |
---|---|---|
committer | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2016-08-26 11:00:36 +0100 |
commit | 0955507f6e7144c9c5e420bbcf617593b13de38b (patch) | |
tree | 01e7b1d24870728adf17b1bca5d21e2f937ef197 /ld/testsuite/ld-arm | |
parent | 4edcc97c1a892325fcda1abe0d383802cc87a869 (diff) | |
download | gdb-0955507f6e7144c9c5e420bbcf617593b13de38b.zip gdb-0955507f6e7144c9c5e420bbcf617593b13de38b.tar.gz gdb-0955507f6e7144c9c5e420bbcf617593b13de38b.tar.bz2 |
Add support for stable secure gateway veneers addresses
2016-08-26 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add a new parameter for
the input import library bfd.
* bfd-in2.h: Regenerate.
* elf32-arm.c (struct elf32_arm_link_hash_table): New in_implib_bfd
and new_cmse_stub_offset fields.
(stub_hash_newfunc): Initialize stub_offset and stub_template_size to
-1.
(elf32_arm_add_stub): Likewise for stub_offset.
(arm_new_stubs_start_offset_ptr): New function.
(arm_build_one_stub): Only allocate a stub_offset if it is -1. Allow
empty SG veneers to have zero relocations.
(arm_size_one_stub): Only initialize stub size and template
information for non empty veneers. Do not update veneer section size
if veneer already has an offset.
(elf32_arm_create_stub): Return the stub entry pointer or NULL instead
of a boolean indicating success or failure.
(cmse_scan): Change stub_changed parameter into an integer pointer
parameter cmse_stub_created to count the number of stub created and
adapt to change of return value in elf32_arm_create_stub.
(cmse_entry_fct_p): New function.
(arm_list_new_cmse_stub): Likewise.
(set_cmse_veneer_addr_from_implib): Likewise.
(elf32_arm_size_stubs): Define cmse_stub_created, pass its address to
cmse_scan instead of that of cmse_stub_changed to compute the number
of stub created and use it to initialize stub_changed. Call
set_cmse_veneer_addr_from_implib after all cmse_scan. Adapt to change
of return value in elf32_arm_create_stub. Use
arm_stub_section_start_offset () if not NULL to initialize size of
secure gateway veneers section. Initialize stub_offset of Cortex-A8
erratum fix to -1. Use ret to hold return value.
(elf32_arm_build_stubs): Use arm_stub_section_start_offset () if not
NULL to initialize size of secure gateway veneers section. Adapt
comment to stress the importance of zeroing veneer section content.
(bfd_elf32_arm_set_target_relocs): Add new in_implib_bfd parameter to
initialize eponymous field in struct elf32_arm_link_hash_table.
ld/
* emultempl/armelf.em (in_implib_filename): Declare and initialize new
variable.
(arm_elf_create_output_section_statements): Open import input library
file for writing and pass resulting in_implib_bfd to
bfd_elf32_arm_set_target_relocs.
(PARSE_AND_LIST_PROLOGUE): Define OPTION_IN_IMPLIB option.
(PARSE_AND_LIST_LONGOPTS): Define --in-implib option.
(PARSE_AND_LIST_OPTIONS): Add help message for --in-implib option.
(PARSE_AND_LIST_ARGS_CASES): Handle new OPTION_IN_IMPLIB case.
* ld.texinfo (--cmse-implib): Update to mention --in-implib.
(--in-implib): Document new option.
* NEWS: Likewise.
* testsuite/ld-arm/arm-elf.exp
(Secure gateway import library generation): add --defsym VER=1 to gas
CLI.
(Secure gateway import library generation: errors): Likewise.
(Input secure gateway import library): New test.
(Input secure gateway import library: no output import library):
Likewise.
(Input secure gateway import library: not an SG input import library):
Likewise.
(Input secure gateway import library: earlier stub section base):
Likewise.
(Input secure gateway import library: later stub section base):
Likewise.
(Input secure gateway import library: veneer comeback): Likewise.
(Input secure gateway import library: entry function change):
Likewise.
* testsuite/ld-arm/cmse-implib.s: Add input import library testing.
* testsuite/ld-arm/cmse-implib.rd: Update accordingly.
* testsuite/ld-arm/cmse-new-implib.out: New file.
* testsuite/ld-arm/cmse-new-implib.rd: Likewise.
* testsuite/ld-arm/cmse-new-implib-no-output.out: Likewise.
* testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out: Likewise.
* testsuite/ld-arm/cmse-new-earlier-later-implib.out: Likewise.
* testsuite/ld-arm/cmse-new-comeback-implib.rd: Likewise.
* testsuite/ld-arm/cmse-new-wrong-implib.out: Likewise.
Diffstat (limited to 'ld/testsuite/ld-arm')
-rw-r--r-- | ld/testsuite/ld-arm/arm-elf.exp | 47 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-implib.s | 17 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-comeback-implib.rd | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-earlier-later-implib.out | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-implib-no-output.out | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-implib.out | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-implib.rd | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/cmse-new-wrong-implib.out | 3 |
9 files changed, 104 insertions, 2 deletions
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 5524085..24d0b4c 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -670,16 +670,59 @@ set armeabitests_nonacl { "cmse-veneers-mainline"} {"Secure gateway import library generation: errors" "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-implib.lib --cmse-implib" "" - "-march=armv8-m.base -mthumb --defsym CHECK_ERRORS=1" + "-march=armv8-m.base -mthumb --defsym CHECK_ERRORS=1 --defsym VER=1" {cmse-implib.s} {{ld cmse-implib-errors.out}} "cmse-implib"} {"Secure gateway import library generation" "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-implib.lib --cmse-implib" "" - "-march=armv8-m.base -mthumb" + "-march=armv8-m.base -mthumb --defsym VER=1" {cmse-implib.s} {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}} "cmse-implib"} + {"Input secure gateway import library" + "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=2" + {cmse-implib.s} + {{ld cmse-new-implib.out} + {readelf {-s tmpdir/cmse-new-implib.lib} cmse-new-implib.rd}} + "cmse-new-implib"} + {"Input secure gateway import library: no output import library" + "--section-start .gnu.sgstubs=0x20000 --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=2" + {cmse-implib.s} + {{ld cmse-new-implib-no-output.out}} + "cmse-new-implib-no-output"} + {"Input secure gateway import library: not an SG input import library" + "--section-start .gnu.sgstubs=0x20000 --in-implib=tmpdir/cmse-implib.lib" "" + "-march=armv8-m.base -mthumb --defsym VER=2" + {cmse-implib.s} + {{ld cmse-new-implib-not-sg-in-implib.out}} + "cmse-new-implib-not-sg-in-implib"} + {"Input secure gateway import library: earlier stub section base" + "--section-start .gnu.sgstubs=0x19000 --out-implib=tmpdir/cmse-new-earlier-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=2" + {cmse-implib.s} + {{ld cmse-new-earlier-later-implib.out}} + "cmse-new-earlier-implib"} + {"Input secure gateway import library: later stub section base" + "--section-start .gnu.sgstubs=0x30000 --out-implib=tmpdir/cmse-new-later-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=2" + {cmse-implib.s} + {{ld cmse-new-earlier-later-implib.out}} + "cmse-new-later-implib"} + {"Input secure gateway import library: veneer comeback" + "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-comeback-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=3" + {cmse-implib.s} + {{readelf {-s tmpdir/cmse-new-comeback-implib.lib} cmse-new-comeback-implib.rd}} + "cmse-new-comeback-implib"} + {"Input secure gateway import library: entry function change" + "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-wrong-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" + "-march=armv8-m.base -mthumb --defsym VER=4" + {cmse-implib.s} + {{ld cmse-new-wrong-implib.out}} + "cmse-new-wrong-implib"} {"R_ARM_THM_JUMP19 Relocation veneers: Short" "--section-start destsect=0x000108002 --section-start .text=0x8000" "" diff --git a/ld/testsuite/ld-arm/cmse-implib.s b/ld/testsuite/ld-arm/cmse-implib.s index a42da63..9dd7839 100644 --- a/ld/testsuite/ld-arm/cmse-implib.s +++ b/ld/testsuite/ld-arm/cmse-implib.s @@ -20,12 +20,29 @@ __acle_se_\name: .endm @ Valid setups for veneer generation +.if (VER >= 2) + entry exported_entry_veneer1, global +.endif +.if (VER != 4) entry exported_entry_veneer2, global +.else + entry exported_entry_veneer2, weak +.endif +.if (VER != 2) entry exported_entry_veneer3, global +.endif +.if (VER > 1) + entry exported_entry_veneer4, global +.endif @ Valid setup for entry function without veneer generation entry exported_entry_fct1, global, sg +.if (VER != 4) entry exported_entry_fct2, global, sg +.else + @ Invalid setup for entry function without veneer generation + entry exported_entry_fct2, global, nop +.endif @ Normal symbol not exported to SG import library .align 2 diff --git a/ld/testsuite/ld-arm/cmse-new-comeback-implib.rd b/ld/testsuite/ld-arm/cmse-new-comeback-implib.rd new file mode 100644 index 0000000..c88d9d5 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-comeback-implib.rd @@ -0,0 +1,15 @@ +File: tmpdir/cmse-new-.*implib.lib + +Symbol table '.symtab' contains 7 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00020001 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer3 + 2: 00020011 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer4 + 3: 00020019 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer1 + 4: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct1 + 5: 00020009 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer2 + 6: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct2 + +File: tmpdir/cmse-new-.*implib + +#... diff --git a/ld/testsuite/ld-arm/cmse-new-earlier-later-implib.out b/ld/testsuite/ld-arm/cmse-new-earlier-later-implib.out new file mode 100644 index 0000000..b49ad0a --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-earlier-later-implib.out @@ -0,0 +1,3 @@ +.*: Entry function `exported_entry_veneer3' disappeared from secure code. +.*: Start address of `.gnu.sgstubs' is different from previous link. +.*: cannot size stub section: Invalid operation diff --git a/ld/testsuite/ld-arm/cmse-new-implib-no-output.out b/ld/testsuite/ld-arm/cmse-new-implib-no-output.out new file mode 100644 index 0000000..0590b71 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-implib-no-output.out @@ -0,0 +1,4 @@ +.*: Entry function `exported_entry_veneer3' disappeared from secure code. +.*: new entry function\(s\) introduced but no output import library specified: +.*: exported_entry_veneer4 +.*: exported_entry_veneer1 diff --git a/ld/testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out b/ld/testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out new file mode 100644 index 0000000..c93c3fb --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out @@ -0,0 +1,2 @@ +.*: --in-implib only supported for Secure Gateway import libraries. +.*: cannot size stub section: Invalid operation diff --git a/ld/testsuite/ld-arm/cmse-new-implib.out b/ld/testsuite/ld-arm/cmse-new-implib.out new file mode 100644 index 0000000..c8af280 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-implib.out @@ -0,0 +1 @@ +.*: Entry function `exported_entry_veneer3' disappeared from secure code. diff --git a/ld/testsuite/ld-arm/cmse-new-implib.rd b/ld/testsuite/ld-arm/cmse-new-implib.rd new file mode 100644 index 0000000..9ff0fd8 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-implib.rd @@ -0,0 +1,14 @@ +File: tmpdir/cmse-new-.*implib.lib + +Symbol table '.symtab' contains 6 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00020011 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer4 + 2: 00020019 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer1 + 3: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct1 + 4: 00020009 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer2 + 5: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct2 + +File: tmpdir/cmse-new-.*implib + +#... diff --git a/ld/testsuite/ld-arm/cmse-new-wrong-implib.out b/ld/testsuite/ld-arm/cmse-new-wrong-implib.out new file mode 100644 index 0000000..2afe407 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-new-wrong-implib.out @@ -0,0 +1,3 @@ +.*: .*: visibility of symbol `exported_entry_veneer2' has changed. +.*: `exported_entry_fct2' refers to a non entry function. +.*: cannot size stub section: Invalid operation |