Fix linking MSP430 files created by gcc's LTO optimizer.
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Wed, 21 Nov 2018 16:21:25 +0000 (16:21 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 21 Nov 2018 16:21:25 +0000 (16:21 +0000)
When invoking GCC with "-g -flto", the compiler will create LTO objects
with debug information. The objects created are "simple ELF" objects (see
libiberty/simple-object-elf.c) and do not have target-specific sections.

When the MSP430 linker sees one of these objects without a .MSP430.attributes
section it errors:

> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses MSP430X instructions but /tmp/ccynqIwudebugobj uses unknown
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small code model whereas /tmp/ccynqIwudebugobj uses the unknown code model
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small data model whereas /tmp/ccynqIwudebugobj uses the unknown data model
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small code model but /tmp/ccynqIwudebugobj uses the unknown data model
> failed to merge target specific data of file /tmp/cc4LhbEI.ltrans0.ltrans.o

The following patch allows these debug LTO objects to be linked with other
MSP430 objects even if they do not have a .MSP430.attributes section.

bfd * elf32-msp430.c (elf32_msp430_merge_mspabi_attributes): Do not
error when .MSP430.attributes section is missing from objects
created by LTO.

bfd/ChangeLog
bfd/elf32-msp430.c

index ffde4c90a76cac0461dfe58d1f4d1862aaaa9dfa..35f0706bf837492bbeac82453e79340b48f62820 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-21  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+       * elf32-msp430.c (elf32_msp430_merge_mspabi_attributes): Do not
+       error when .MSP430.attributes section is missing from objects
+       created by LTO.
+
 2018-11-13  Jim Wilson  <jimw@sifive.com>
 
        * elfnn-riscv.c (riscv_float_abi_string): New.
index 2d351d3906cc5f985d43d9b6766ae2b2ab100b90..95dae2ef2fff04fa2cc2806376d585dadc391834 100644 (file)
@@ -2424,6 +2424,12 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info)
   if (ibfd->flags & BFD_LINKER_CREATED)
     return TRUE;
 
+  /* LTO can create temporary files for linking which may not have an attribute
+     section.  */
+  if (ibfd->lto_output
+      && bfd_get_section_by_name (ibfd, ".MSP430.attributes") == NULL)
+    return TRUE;
+
   /* If this is the first real object just copy the attributes.  */
   if (!elf_known_obj_attributes_proc (obfd)[0].i)
     {
This page took 0.02611 seconds and 4 git commands to generate.