]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make import libraries relocatable objects
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Tue, 20 Jun 2017 10:21:49 +0000 (11:21 +0100)
committerThomas Preud'homme <thomas.preudhomme@arm.com>
Tue, 20 Jun 2017 10:23:24 +0000 (11:23 +0100)
For ELF targets --out-implib currently generates an executable file
(e_type is ET_EXEC) despite the file being expected to be linked against
some other object file to make an executable later. It seems therefore
more sensible to make the import library a relocatable object file
(e_type set to ET_REL).

Incidentally, as dicted by requirement 8 of
"ARM v8-M Security Extensions: Requirements on Development Tools"
(document ARM-ECM-0359818) version 1.0, import libraries generated when
using --cmse-implib *must* be relocatable object file so this commit
also adds an assert there in case the type of ELF import library is
changed again in the future.

2017-06-20  Thomas Preud'homme  <thomas.preudhomme@arm.com>

Backport from mainline
2017-05-08  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
* elflink.c (elf_output_implib): Remove executable flag from import
library bfd.
* elf32-arm.c (elf32_arm_filter_implib_symbols): Assert that the import
library is a relocatable object file.

gas/
* testsuite/ld-arm/arm-elf.exp
(Secure gateway import library generation): Check e_type field
of import library and executable produced.
* testsuite/ld-arm/cmse-implib.type: Expectations for e_type field.

bfd/ChangeLog
bfd/elf32-arm.c
bfd/elflink.c
gas/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/cmse-implib.type [new file with mode: 0644]

index 7d7416941fdc0039a572b57f1de8df8e407f3291..cae30e6b20ed0b698cb7585fe2dad9a0ee31f7fa 100644 (file)
@@ -1,3 +1,13 @@
+2017-06-20  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       Backport from mainline
+       2017-05-08  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       * elflink.c (elf_output_implib): Remove executable flag from import
+       library bfd.
+       * elf32-arm.c (elf32_arm_filter_implib_symbols): Assert that the import
+       library is a relocatable object file.
+
 2017-06-13  Nick Clifton  <nickc@redhat.com>
 
        Import this fix from the mainline sources:
index cc8fd15cadebcf367372e770a530c1652b2e0476..90286a84fa6ca40c6ebdbe003367b5b4b09992cd 100644 (file)
@@ -17500,6 +17500,10 @@ elf32_arm_filter_implib_symbols (bfd *abfd ATTRIBUTE_UNUSED,
 {
   struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (info);
 
+  /* Requirement 8 of "ARM v8-M Security Extensions: Requirements on
+     Development Tools" (ARM-ECM-0359818) mandates Secure Gateway import
+     library to be a relocatable object file.  */
+  BFD_ASSERT (!(bfd_get_file_flags (info->out_implib_bfd) & EXEC_P));
   if (globals->cmse_implib)
     return elf32_arm_filter_cmse_symbols (abfd, info, syms, symcount);
   else
index cd03a1375774de69db05f30860df1b28e1912d14..f82bd8202bac6e87251576ae63102871b1dc7dc4 100644 (file)
@@ -11146,10 +11146,11 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info)
   if (!bfd_set_format (implib_bfd, bfd_object))
     return FALSE;
 
+  /* Use flag from executable but make it a relocatable object.  */
   flags = bfd_get_file_flags (abfd);
   flags &= ~HAS_RELOC;
   if (!bfd_set_start_address (implib_bfd, 0)
-      || !bfd_set_file_flags (implib_bfd, flags))
+      || !bfd_set_file_flags (implib_bfd, flags & ~EXEC_P))
     return FALSE;
 
   /* Copy architecture of output file to import library file.  */
index a05355a1484d78ba387dd55ed356299e065e93e0..e75237552bbae5388c5affc5f8dadee284c28890 100644 (file)
@@ -1,3 +1,13 @@
+2017-06-20  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       Backport from mainline
+       2017-05-08  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       * testsuite/ld-arm/arm-elf.exp
+       (Secure gateway import library generation): Check e_type field
+       of import library and executable produced.
+       * testsuite/ld-arm/cmse-implib.type: Expectations for e_type field.
+
 2017-06-05  Alan Modra  <amodra@gmail.com>
 
        Apply from master
index 1a4d262e60816f6ebaa44e54a32125985bf7d0f2..2e193324907e71b86d56f9c82adca1cae3c025a8 100644 (file)
@@ -685,7 +685,8 @@ set armeabitests_nonacl {
      "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-implib.lib --cmse-implib" ""
      "-march=armv8-m.base -mthumb --defsym VER=1"
      {cmse-implib.s}
-     {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}}
+     {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}
+      {readelf {-h tmpdir/cmse-implib.lib} cmse-implib.type}}
      "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" ""
diff --git a/ld/testsuite/ld-arm/cmse-implib.type b/ld/testsuite/ld-arm/cmse-implib.type
new file mode 100644 (file)
index 0000000..7bb3bcc
--- /dev/null
@@ -0,0 +1,9 @@
+#...
+File: tmpdir/cmse-implib.lib
+#...
+[[:space:]]+Type:[[:space:]]+REL \(Relocatable file\)
+#...
+File: tmpdir/cmse-implib
+#...
+[[:space:]]+Type:[[:space:]]+EXEC \(Executable file\)
+#...