aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2016-08-26 10:59:26 +0100
committerThomas Preud'homme <thomas.preudhomme@arm.com>2016-08-26 11:00:36 +0100
commit0955507f6e7144c9c5e420bbcf617593b13de38b (patch)
tree01e7b1d24870728adf17b1bca5d21e2f937ef197 /ld/emultempl
parent4edcc97c1a892325fcda1abe0d383802cc87a869 (diff)
downloadgdb-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/emultempl')
-rw-r--r--ld/emultempl/armelf.em27
1 files changed, 26 insertions, 1 deletions
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 2678740..306caf1 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -43,6 +43,7 @@ static int pic_veneer = 0;
static int merge_exidx_entries = -1;
static int fix_arm1176 = 1;
static int cmse_implib = 0;
+static char *in_implib_filename = NULL;
static void
gld${EMULATION_NAME}_before_parse (void)
@@ -499,6 +500,8 @@ gld${EMULATION_NAME}_finish (void)
static void
arm_elf_create_output_section_statements (void)
{
+ bfd *in_implib_bfd;
+
if (strstr (bfd_get_target (link_info.output_bfd), "arm") == NULL)
{
/* The arm backend needs special fields in the output hash structure.
@@ -509,6 +512,20 @@ arm_elf_create_output_section_statements (void)
return;
}
+ if (in_implib_filename)
+ {
+ in_implib_bfd = bfd_openr (in_implib_filename,
+ bfd_get_target (link_info.output_bfd));
+
+ if (in_implib_bfd == NULL)
+ einfo ("%F%s: Can't open: %E\n", in_implib_filename);
+
+ if (!bfd_check_format (in_implib_bfd, bfd_object))
+ einfo ("%F%s: Not a relocatable file: %E\n", in_implib_filename);
+ }
+ else
+ in_implib_bfd = NULL;
+
bfd_elf32_arm_set_target_relocs (link_info.output_bfd, &link_info,
target1_is_rel,
target2_type, fix_v4bx, use_blx,
@@ -516,7 +533,7 @@ arm_elf_create_output_section_statements (void)
no_enum_size_warning,
no_wchar_size_warning,
pic_veneer, fix_cortex_a8,
- fix_arm1176, cmse_implib);
+ fix_arm1176, cmse_implib, in_implib_bfd);
stub_file = lang_add_input_file ("linker stubs",
lang_input_file_is_fake_enum,
@@ -586,6 +603,7 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_LONG_PLT 319
#define OPTION_STM32L4XX_FIX 320
#define OPTION_CMSE_IMPLIB 321
+#define OPTION_IN_IMPLIB 322
'
PARSE_AND_LIST_SHORTOPTS=p
@@ -613,6 +631,7 @@ PARSE_AND_LIST_LONGOPTS='
{ "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 },
+ { "in-implib", required_argument, NULL, OPTION_IN_IMPLIB },
'
PARSE_AND_LIST_OPTIONS='
@@ -635,6 +654,8 @@ PARSE_AND_LIST_OPTIONS='
" 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, _(" --in-implib Import library whose symbols address must\n"
+ " remain stable\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\
@@ -759,6 +780,10 @@ PARSE_AND_LIST_ARGS_CASES='
case OPTION_CMSE_IMPLIB:
cmse_implib = 1;
break;
+
+ case OPTION_IN_IMPLIB:
+ in_implib_filename = optarg;
+ break;
'
# We have our own before_allocation etc. functions, but they call