aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2016-08-04 15:54:57 +0100
committerThomas Preud'homme <thomas.preudhomme@arm.com>2016-08-04 15:54:57 +0100
commit54ddd295b505efe4b07cc1e939d4e150032603d8 (patch)
tree58c9a2c7639072764628a540c2340e221e3b87d5 /ld
parent4ba2ef8fbe74716708e5ce0bcba4f3b1cc8ac99a (diff)
downloadgdb-54ddd295b505efe4b07cc1e939d4e150032603d8.zip
gdb-54ddd295b505efe4b07cc1e939d4e150032603d8.tar.gz
gdb-54ddd295b505efe4b07cc1e939d4e150032603d8.tar.bz2
2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/ * bfd-in.h (bfd_elf32_arm_set_target_relocs): Add one parameter. * bfd-in2.h: Regenerate. * elf32-arm.c (struct elf32_arm_link_hash_table): Declare new cmse_implib field. (bfd_elf32_arm_set_target_relocs): Add new parameter to initialize cmse_implib field in struct elf32_arm_link_hash_table. (elf32_arm_filter_cmse_symbols): New function. (elf32_arm_filter_implib_symbols): Likewise. (elf_backend_filter_implib_symbols): Define to elf32_arm_filter_implib_symbols. ld/ * emultempl/armelf.em (cmse_implib): Declare and define this new static variable. (arm_elf_create_output_section_statements): Add new cmse_implib parameter. (OPTION_CMSE_IMPLIB): Define macro. (PARSE_AND_LIST_LONGOPTS): Add entry for new --cmse-implib switch. (PARSE_AND_LIST_OPTIONS): Likewise. (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_CMSE_IMPLIB case. * ld.texinfo (--cmse-implib): Document new option. * testsuite/ld-arm/arm-elf.exp (Secure gateway import library generation): New test. (Secure gateway import library generation: errors): Likewise. * testsuite/ld-arm/cmse-implib.s: New file. * testsuite/ld-arm/cmse-implib-errors.out: Likewise. * testsuite/ld-arm/cmse-implib.rd: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog18
-rw-r--r--ld/emultempl/armelf.em11
-rw-r--r--ld/ld.texinfo7
-rw-r--r--ld/testsuite/ld-arm/arm-elf.exp12
-rw-r--r--ld/testsuite/ld-arm/cmse-implib-errors.out7
-rw-r--r--ld/testsuite/ld-arm/cmse-implib.rd13
-rw-r--r--ld/testsuite/ld-arm/cmse-implib.s58
7 files changed, 125 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 49f7972..6dcb8ee 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,23 @@
2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
+ * emultempl/armelf.em (cmse_implib): Declare and define this new
+ static variable.
+ (arm_elf_create_output_section_statements): Add new cmse_implib
+ parameter.
+ (OPTION_CMSE_IMPLIB): Define macro.
+ (PARSE_AND_LIST_LONGOPTS): Add entry for new --cmse-implib switch.
+ (PARSE_AND_LIST_OPTIONS): Likewise.
+ (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_CMSE_IMPLIB case.
+ * ld.texinfo (--cmse-implib): Document new option.
+ * testsuite/ld-arm/arm-elf.exp
+ (Secure gateway import library generation): New test.
+ (Secure gateway import library generation: errors): Likewise.
+ * testsuite/ld-arm/cmse-implib.s: New file.
+ * testsuite/ld-arm/cmse-implib-errors.out: Likewise.
+ * testsuite/ld-arm/cmse-implib.rd: Likewise.
+
+2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
+
* ld.texinfo (Placement of SG veneers): New concept entry.
* testsuite/ld-arm/arm-elf.exp
(Secure gateway veneers: no .gnu.sgstubs section): New test.
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 6074824..c21f6a8 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -42,6 +42,7 @@ static int no_wchar_size_warning = 0;
static int pic_veneer = 0;
static int merge_exidx_entries = -1;
static int fix_arm1176 = 1;
+static int cmse_implib = 0;
static void
gld${EMULATION_NAME}_before_parse (void)
@@ -514,7 +515,7 @@ arm_elf_create_output_section_statements (void)
no_enum_size_warning,
no_wchar_size_warning,
pic_veneer, fix_cortex_a8,
- fix_arm1176);
+ fix_arm1176, cmse_implib);
stub_file = lang_add_input_file ("linker stubs",
lang_input_file_is_fake_enum,
@@ -583,6 +584,7 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_NO_FIX_ARM1176 318
#define OPTION_LONG_PLT 319
#define OPTION_STM32L4XX_FIX 320
+#define OPTION_CMSE_IMPLIB 321
'
PARSE_AND_LIST_SHORTOPTS=p
@@ -609,6 +611,7 @@ PARSE_AND_LIST_LONGOPTS='
{ "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
{ "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
{ "long-plt", no_argument, NULL, OPTION_LONG_PLT },
+ { "cmse-implib", no_argument, NULL, OPTION_CMSE_IMPLIB },
'
PARSE_AND_LIST_OPTIONS='
@@ -629,6 +632,8 @@ PARSE_AND_LIST_OPTIONS='
fprintf (file, _(" --pic-veneer Always generate PIC interworking veneers\n"));
fprintf (file, _(" --long-plt Generate long .plt entries\n"
" to handle large .plt/.got displacements\n"));
+ fprintf (file, _(" --cmse-implib Make import library to be a secure gateway import\n"
+ " library as per ARMv8-M Security Extensions\n"));
fprintf (file, _("\
--stub-group-size=N Maximum size of a group of input sections that\n\
can be handled by one stub section. A negative\n\
@@ -749,6 +754,10 @@ PARSE_AND_LIST_ARGS_CASES='
case OPTION_LONG_PLT:
bfd_elf32_arm_use_long_plt ();
break;
+
+ case OPTION_CMSE_IMPLIB:
+ cmse_implib = 1;
+ break;
'
# We have our own before_allocation etc. functions, but they call
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index af8cee3..e6813f2 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -6859,6 +6859,13 @@ Its start address must be set, either with the command line option
@samp{--section-start} or in a linker script, to indicate where to place these
veneers in memory.
+@kindex --cmse-implib
+@cindex Secure gateway import library
+The @samp{--cmse-implib} option requests that the import libraries
+specified by the @samp{--out-implib} and @samp{--in-implib} options are
+secure gateway import libraries, suitable for linking a non-secure
+executable against secure code as per ARMv8-M Security Extensions.
+
@ifclear GENERIC
@lowersections
@end ifclear
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index b3c8a84..5524085 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -668,6 +668,18 @@ set armeabitests_nonacl {
{objdump {-h -j .gnu.sgstubs} cmse-veneers.sd}
{nm {} cmse-veneers.rd}}
"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"
+ {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"
+ {cmse-implib.s}
+ {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}}
+ "cmse-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-errors.out b/ld/testsuite/ld-arm/cmse-implib-errors.out
new file mode 100644
index 0000000..0026f6b
--- /dev/null
+++ b/ld/testsuite/ld-arm/cmse-implib-errors.out
@@ -0,0 +1,7 @@
+.*: .*: absent standard symbol `not_exported_fct2'.
+.*: .*: invalid special symbol `__acle_se_not_exported_pseudoentry_var'.
+.*: It must be a global or weak function symbol.
+.*: .*: invalid standard symbol `not_exported_pseudoentry_var'.
+.*: It must be a global or weak function symbol.
+.* cannot size stub section: Invalid operation
+#...
diff --git a/ld/testsuite/ld-arm/cmse-implib.rd b/ld/testsuite/ld-arm/cmse-implib.rd
new file mode 100644
index 0000000..c5f7aef
--- /dev/null
+++ b/ld/testsuite/ld-arm/cmse-implib.rd
@@ -0,0 +1,13 @@
+File: tmpdir/cmse-implib.lib
+
+Symbol table '.symtab' contains 5 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: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct1
+ 3: 00020009 8 FUNC GLOBAL DEFAULT ABS exported_entry_veneer2
+ 4: [0-9a-f]+ 6 FUNC GLOBAL DEFAULT ABS exported_entry_fct2
+
+File: tmpdir/cmse-implib
+
+#...
diff --git a/ld/testsuite/ld-arm/cmse-implib.s b/ld/testsuite/ld-arm/cmse-implib.s
new file mode 100644
index 0000000..a42da63
--- /dev/null
+++ b/ld/testsuite/ld-arm/cmse-implib.s
@@ -0,0 +1,58 @@
+ .syntax unified
+ .text
+
+.macro entry name, vis, entry_fct
+ .align 2
+ .\vis \name
+ .\vis __acle_se_\name
+ .thumb
+ .thumb_func
+ .type \name, %function
+ .type __acle_se_\name, %function
+\name:
+.ifnb \entry_fct
+ \entry_fct
+.endif
+__acle_se_\name:
+ nop
+ .size \name, .-\name
+ .size __acle_se_\name, .-__acle_se_\name
+.endm
+
+ @ Valid setups for veneer generation
+ entry exported_entry_veneer2, global
+ entry exported_entry_veneer3, global
+
+ @ Valid setup for entry function without veneer generation
+ entry exported_entry_fct1, global, sg
+ entry exported_entry_fct2, global, sg
+
+ @ Normal symbol not exported to SG import library
+ .align 2
+ .global not_exported_fct1
+ .type not_exported_fct1, %function
+not_exported_fct1:
+ nop
+ .size not_exported_fct1, .-not_exported_fct1
+
+.ifdef CHECK_ERRORS
+ @ Invalid setups for export to SG import library
+ .align 2
+ .global __acle_se_not_exported_fct2
+ .type __acle_se_not_exported_fct2, %function
+__acle_se_not_exported_fct2:
+ nop
+ .size __acle_se_not_exported_fct2, .-__acle_se_not_exported_fct2
+
+ .align 2
+ .global __acle_se_not_exported_pseudoentry_var
+ .global not_exported_pseudoentry_var
+ .data
+ .type __acle_se_not_exported_pseudoentry_var, %object
+ .type not_exported_pseudoentry_var, %object
+ .size not_exported_pseudoentry_var, 4
+ .size __acle_se_not_exported_pseudoentry_var, 4
+__acle_se_not_exported_pseudoentry_var:
+not_exported_pseudoentry_var:
+ .word 42
+.endif