]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fixes the generation of dwarf line debug information for the msp430, even in the...
authorNick Clifton <nickc@redhat.com>
Mon, 23 Feb 2015 14:53:02 +0000 (14:53 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 23 Feb 2015 14:53:02 +0000 (14:53 +0000)
PR 17940
* dwarf2dbg.c (out_header): When generating dwarf sections use
real symbols not temps for the start and end symbols.
* config/tc-msp430.h (TC_FORCE_RELOCATION_SUB_SAME): Also prevent
adjustments to relocations in debug sections.
(TC_LINKRELAX_FIXUP): Likewise.

* elf32-msp430.c (msp430_elf_relax_delete_bytes): Adjust debug
symbols at end of sections.  Adjust function sizes.

bfd/ChangeLog
bfd/elf32-msp430.c
gas/ChangeLog
gas/config/tc-msp430.h
gas/dwarf2dbg.c

index e9fb08ba54b9f7de2a349a2ebaae908ae6fa95a3..f4391d7b0c161055bf9407e71e89754a56dde89f 100644 (file)
@@ -3,6 +3,10 @@
        PR 17914
        * cpu-w65.c: Correct typos in license notice.
 
+       PR 17940
+       * elf32-msp430.c (msp430_elf_relax_delete_bytes): Adjust debug
+       symbols at end of sections.  Adjust function sizes.
+
 2015-02-20  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * elf-bfd.h (elfcore_write_s390_vxrs_low): Add prototype.
index c839ea0d1fc29ce0f4f712d6bca44333ac424dee..fdab3d3ee5eb5884f3c02235cf327f53b1f86c36 100644 (file)
@@ -1656,9 +1656,38 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr,
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   isym = (Elf_Internal_Sym *) symtab_hdr->contents;
   for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
-    if (isym->st_shndx == sec_shndx
-       && isym->st_value > addr && isym->st_value < toaddr)
-      isym->st_value -= count;
+    {
+      const char * name;
+
+      name = bfd_elf_string_from_elf_section
+       (abfd, symtab_hdr->sh_link, isym->st_name);
+      name = (name == NULL || * name == 0) ? bfd_section_name (abfd, sec) : name;
+
+      if (isym->st_shndx != sec_shndx)
+       continue;
+      
+      if (isym->st_value > addr
+         && (isym->st_value < toaddr
+             /* We also adjust a symbol at the end of the section if its name is
+                on the list below.  These symbols are used for debug info
+                generation and they refer to the end of the current section, not
+                the start of the next section.  */
+             || (isym->st_value == toaddr
+                 && name != NULL
+                 && (CONST_STRNEQ (name, ".Letext")
+                     || CONST_STRNEQ (name, ".LFE")))))
+       {
+         if (isym->st_value < addr + count)
+           isym->st_value = addr;
+         else
+           isym->st_value -= count;
+       }
+      /* Adjust the function symbol's size as well.  */
+      else if (ELF_ST_TYPE (isym->st_info) == STT_FUNC
+              && isym->st_value + isym->st_size > addr
+              && isym->st_value + isym->st_size < toaddr)
+       isym->st_size -= count;
+    }
 
   /* Now adjust the global symbols defined in this section.  */
   symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
@@ -1674,7 +1703,19 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr,
          && sym_hash->root.u.def.section == sec
          && sym_hash->root.u.def.value > addr
          && sym_hash->root.u.def.value < toaddr)
-       sym_hash->root.u.def.value -= count;
+       {
+         if (sym_hash->root.u.def.value < addr + count)
+           sym_hash->root.u.def.value = addr;
+         else
+           sym_hash->root.u.def.value -= count;
+       }
+      /* Adjust the function symbol's size as well.  */
+      else if (sym_hash->root.type == bfd_link_hash_defined
+              && sym_hash->root.u.def.section == sec
+              && sym_hash->type == STT_FUNC
+              && sym_hash->root.u.def.value + sym_hash->size > addr
+              && sym_hash->root.u.def.value + sym_hash->size < toaddr)
+       sym_hash->size -= count;
     }
 
   return TRUE;
index fe711bfd78bda159a1d6e6e27a72bb25e3942c0a..93dd2dd267e8ca960333bab6c353008aca58300f 100644 (file)
@@ -1,3 +1,12 @@
+2015-02-23  Nick Clifton  <nickc@redhat.com>
+
+       PR 17940
+       * dwarf2dbg.c (out_header): When generating dwarf sections use
+       real symbols not temps for the start and end symbols.
+       * config/tc-msp430.h (TC_FORCE_RELOCATION_SUB_SAME): Also prevent
+       adjustments to relocations in debug sections.
+       (TC_LINKRELAX_FIXUP): Likewise.
+
 2015-02-19  Alan Modra  <amodra@gmail.com>
 
        * doc/as.texinfo (Local Symbol Names): Don't use ':' in pxref.
index 657dc1a8dbf5a678e8ff23d589317da05569253e..08115ac51878fec8c8c2cecdb88b026db9be2ed0 100644 (file)
@@ -159,7 +159,8 @@ extern bfd_boolean msp430_allow_local_subtract (expressionS *, expressionS *, se
    linker, but this fix is simpler, and it pretty much only affects
    object size a little bit.  */
 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
-  (((SEC)->flags & SEC_CODE) != 0              \
+  (   ((SEC)->flags & SEC_CODE) != 0           \
+   || ((SEC)->flags & SEC_DEBUGGING) != 0      \
    || ! SEG_NORMAL (SEC)                       \
    || TC_FORCE_RELOCATION (FIX))
 
@@ -169,4 +170,4 @@ extern bfd_boolean msp430_allow_local_subtract (expressionS *, expressionS *, se
 
 #define DWARF2_USE_FIXED_ADVANCE_PC 1
 
-#define TC_LINKRELAX_FIXUP(seg) (seg->flags & SEC_CODE)
+#define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) || (seg->flags & SEC_DEBUGGING))
index 5dfd980a96ad34b8d1b9f6cb793a6fe089b74606..9177bdf7d85156cf40a475e0697f2fe2f6533dca 100644 (file)
@@ -1467,8 +1467,22 @@ out_header (asection *sec, expressionS *exp)
   symbolS *end_sym;
 
   subseg_set (sec, 0);
-  start_sym = symbol_temp_new_now ();
-  end_sym = symbol_temp_make ();
+#if 1
+  if (flag_dwarf_sections)
+    {
+      /* If we are going to put the start and end symbols in different
+        sections, then we need real symbols, not just fake, local ones.  */
+      frag_now_fix ();
+      start_sym = symbol_make (".Ldebug_line_start");
+      end_sym = symbol_make (".Ldebug_line_end");
+      symbol_set_value_now (start_sym);
+    }
+  else
+#endif
+    {
+      start_sym = symbol_temp_new_now ();
+      end_sym = symbol_temp_make ();
+    }
 
   /* Total length of the information.  */
   exp->X_op = O_subtract;