This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, LD, ping] Make import libraries relocatable objects


Great then. Committed the attached updated patch as per your comments.

Best regards,

Thomas

On 08/05/17 09:51, Nick Clifton wrote:
Hi Thomas,

Will do. Can you confirm you are happy with the target-independent change as well?

I am.

As far as I know only the ARM target is actually using ELF based import libraries at the moment.

Cheers
  Nick


diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 434649f1ca18841320345e7fdf437c4ad47a1428..8dcaf45523e726dc71ff8df8bdbd07ba759120fb 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -17498,6 +17498,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
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 4af4b1cd3d33c0b566349d545038accee4ffd51a..f8555d802f62bc2e2c46d50959f9bd1b2f0a7177 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11271,10 +11271,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.  */
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 1a4d262e60816f6ebaa44e54a32125985bf7d0f2..2e193324907e71b86d56f9c82adca1cae3c025a8 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -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
index 0000000000000000000000000000000000000000..7bb3bccc8e5d0ee99a0b9a2674296673b1c3c349
--- /dev/null
+++ b/ld/testsuite/ld-arm/cmse-implib.type
@@ -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\)
+#...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]