[ARC] Local symbols relocation cleanup
authorClaudiu Zissulescu <claziss@synopsys.com>
Mon, 29 Feb 2016 15:51:11 +0000 (16:51 +0100)
committerClaudiu Zissulescu <claziss@synopsys.com>
Mon, 29 Feb 2016 15:51:11 +0000 (16:51 +0100)
bfd/
2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>

* elf32-arc.c (elf_arc_relocate_section): Added rules to fix the
relocation addend when sections get merged.

gas/
2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>
    Claudiu Zissulescu  <Claudiu.Zissulescu@synopsys.com>

        * config/tc-arc.c (arc_extra_reloc): Change size to 0.
        (tc_arc_fix_adjustable): Changed default return value to 1.
        * testsuite/gas/arc/j.d: Updated expected symbol
        * testsuite/gas/arc/jl.d: Likewise
        * testsuite/gas/arc/relax-avoid1.d: Likewise
        * testsuite/gas/arc/st.d: Likewise

ld/
2016-02-29 Cupertino Miranda  <cmiranda@synopsys.com>

* testsuite/ld-elf/merge.d: Removed xfail for ARC.
* testsuite/ld-elf/merge2.d: Likewise.
* testsuite/ld-elf/merge3.d: Likewise.

12 files changed:
bfd/ChangeLog
bfd/elf32-arc.c
gas/ChangeLog
gas/config/tc-arc.c
gas/testsuite/gas/arc/j.d
gas/testsuite/gas/arc/jl.d
gas/testsuite/gas/arc/relax-avoid1.d
gas/testsuite/gas/arc/st.d
ld/ChangeLog
ld/testsuite/ld-elf/merge.d
ld/testsuite/ld-elf/merge2.d
ld/testsuite/ld-elf/merge3.d

index 5d39624b7db408f66dd2487762901bf0a9ae3f2a..5561f4b5c8d411cd56ff3ebd672e657c224f430c 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>
+
+       * elf32-arc.c (elf_arc_relocate_section): Added rules to fix the
+       relocation addend when sections get merged.
+
 2016-02-29  Cupertino Miranda <Cupertino.Miranda@synopsys.com>
 
        * elf32-arc.c (arc_elf_final_write_processing): Add condition to
index 9993478742bdd635ed044bc5677b5cf41181a8ff..ab2512d11d0cc6db7f1ce5847562c01d5093ee25 100644 (file)
@@ -1158,6 +1158,22 @@ elf_arc_relocate_section (bfd *             output_bfd,
          reloc_data.sym_value = sym->st_value;
          reloc_data.sym_section = sec;
 
+         /* Mergeable section handling.  */
+         if ((sec->flags & SEC_MERGE)
+             && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+           {
+             asection *msec;
+             msec = sec;
+             rel->r_addend = _bfd_elf_rel_local_sym (output_bfd, sym,
+                                                     &msec, rel->r_addend);
+             rel->r_addend -= (sec->output_section->vma
+                               + sec->output_offset
+                               + sym->st_value);
+             rel->r_addend += msec->output_section->vma + msec->output_offset;
+
+             reloc_data.reloc_addend = rel->r_addend;
+           }
+
          if ((is_reloc_for_GOT (howto)
               || is_reloc_for_TLS (howto)) && entry != NULL)
            {
index 1815655183384f94154a417f5af1eb60db4777b5..4a075bb448d38beb22a0e2f2f36399d6d6263ef1 100644 (file)
@@ -1,3 +1,13 @@
+2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>
+           Claudiu Zissulescu  <Claudiu.Zissulescu@synopsys.com>
+
+        * config/tc-arc.c (arc_extra_reloc): Change size to 0.
+        (tc_arc_fix_adjustable): Changed default return value to 1.
+        * testsuite/gas/arc/j.d: Updated expected symbol
+        * testsuite/gas/arc/jl.d: Likewise
+        * testsuite/gas/arc/relax-avoid1.d: Likewise
+        * testsuite/gas/arc/st.d: Likewise
+
 2016-02-29  Claudiu Zissulescu  <Claudiu.Zissulescu@synopsys.com>
 
        * config/tc-arc.c: Enable code density instructions for ARC EM.
index 70a47f9d4b1786e6bc6ad6e048fddc5c2dec2e1c..e509fecb7e7d3a037fd8d3acba82dc3c03ec4de2 100644 (file)
@@ -591,10 +591,31 @@ arc_extra_reloc (int r_type)
       lab = symbol_find_or_make (lab_name);
       restore_line_pointer (c);
     }
+
+  /* These relocations exist as a mechanism for the compiler to tell the
+     linker how to patch the code if the tls model is optimised.  However,
+     the relocation itself does not require any space within the assembler
+     fragment, and so we pass a size of 0.
+
+     The lines that generate these relocations look like this:
+
+         .tls_gd_ld @.tdata`bl __tls_get_addr@plt
+
+     The '.tls_gd_ld @.tdata' is processed first and generates the
+     additional relocation, while the 'bl __tls_get_addr@plt' is processed
+     second and generates the additional branch.
+
+     It is possible that the additional relocation generated by the
+     '.tls_gd_ld @.tdata' will be attached at the very end of one fragment,
+     while the 'bl __tls_get_addr@plt' will be generated as the first thing
+     in the next fragment.  This will be fine; both relocations will still
+     appear to be at the same address in the generated object file.
+     However, this only works as the additional relocation is generated
+     with size of 0 bytes.  */
   fixS *fixP
     = fix_new (frag_now,       /* Which frag?  */
               frag_now_fix (), /* Where in that frag?  */
-              2,               /* size: 1, 2, or 4 usually.  */
+              0,               /* size: 1, 2, or 4 usually.  */
               sym,             /* X_add_symbol.  */
               0,               /* X_add_number.  */
               FALSE,           /* TRUE if PC-relative relocation.  */
@@ -3551,7 +3572,7 @@ tc_arc_fix_adjustable (fixS *fixP)
       break;
     }
 
-  return 0; /* FIXME! return 1, fix it in the linker.  */
+  return 1;
 }
 
 /* Compute the reloc type of an expression EXP.  */
index 8ee8030af7e952b4e8356dbcf52b5512f10c187a..341773a39eb1b2a161d641062cf2f7b0b6595dcd 100644 (file)
@@ -7,61 +7,61 @@ Disassembly of section .text:
 
 [0-9a-f]+ <text_label>:
    0:  2020 0f80 0000 0000     j       0
-                       4: R_ARC_32_ME  text_label
+                       4: R_ARC_32_ME  .text
    8:  20e0 0f80 0000 0000     j       0
-                       c: R_ARC_32_ME  text_label
+                       c: R_ARC_32_ME  .text
   10:  20e0 0f80 0000 0000     j       0
-                       14: R_ARC_32_ME text_label
+                       14: R_ARC_32_ME .text
   18:  20e0 0f81 0000 0000     jeq     0
-                       1c: R_ARC_32_ME text_label
+                       1c: R_ARC_32_ME .text
   20:  20e0 0f81 0000 0000     jeq     0
-                       24: R_ARC_32_ME text_label
+                       24: R_ARC_32_ME .text
   28:  20e0 0f82 0000 0000     jne     0
-                       2c: R_ARC_32_ME text_label
+                       2c: R_ARC_32_ME .text
   30:  20e0 0f82 0000 0000     jne     0
-                       34: R_ARC_32_ME text_label
+                       34: R_ARC_32_ME .text
   38:  20e0 0f83 0000 0000     jp      0
-                       3c: R_ARC_32_ME text_label
+                       3c: R_ARC_32_ME .text
   40:  20e0 0f83 0000 0000     jp      0
-                       44: R_ARC_32_ME text_label
+                       44: R_ARC_32_ME .text
   48:  20e0 0f84 0000 0000     jn      0
-                       4c: R_ARC_32_ME text_label
+                       4c: R_ARC_32_ME .text
   50:  20e0 0f84 0000 0000     jn      0
-                       54: R_ARC_32_ME text_label
+                       54: R_ARC_32_ME .text
   58:  20e0 0f85 0000 0000     jc      0
-                       5c: R_ARC_32_ME text_label
+                       5c: R_ARC_32_ME .text
   60:  20e0 0f85 0000 0000     jc      0
-                       64: R_ARC_32_ME text_label
+                       64: R_ARC_32_ME .text
   68:  20e0 0f85 0000 0000     jc      0
-                       6c: R_ARC_32_ME text_label
+                       6c: R_ARC_32_ME .text
   70:  20e0 0f86 0000 0000     jnc     0
-                       74: R_ARC_32_ME text_label
+                       74: R_ARC_32_ME .text
   78:  20e0 0f86 0000 0000     jnc     0
-                       7c: R_ARC_32_ME text_label
+                       7c: R_ARC_32_ME .text
   80:  20e0 0f86 0000 0000     jnc     0
-                       84: R_ARC_32_ME text_label
+                       84: R_ARC_32_ME .text
   88:  20e0 0f87 0000 0000     jv      0
-                       8c: R_ARC_32_ME text_label
+                       8c: R_ARC_32_ME .text
   90:  20e0 0f87 0000 0000     jv      0
-                       94: R_ARC_32_ME text_label
+                       94: R_ARC_32_ME .text
   98:  20e0 0f88 0000 0000     jnv     0
-                       9c: R_ARC_32_ME text_label
+                       9c: R_ARC_32_ME .text
   a0:  20e0 0f88 0000 0000     jnv     0
-                       a4: R_ARC_32_ME text_label
+                       a4: R_ARC_32_ME .text
   a8:  20e0 0f89 0000 0000     jgt     0
-                       ac: R_ARC_32_ME text_label
+                       ac: R_ARC_32_ME .text
   b0:  20e0 0f8a 0000 0000     jge     0
-                       b4: R_ARC_32_ME text_label
+                       b4: R_ARC_32_ME .text
   b8:  20e0 0f8b 0000 0000     jlt     0
-                       bc: R_ARC_32_ME text_label
+                       bc: R_ARC_32_ME .text
   c0:  20e0 0f8c 0000 0000     jle     0
-                       c4: R_ARC_32_ME text_label
+                       c4: R_ARC_32_ME .text
   c8:  20e0 0f8d 0000 0000     jhi     0
-                       cc: R_ARC_32_ME text_label
+                       cc: R_ARC_32_ME .text
   d0:  20e0 0f8e 0000 0000     jls     0
-                       d4: R_ARC_32_ME text_label
+                       d4: R_ARC_32_ME .text
   d8:  20e0 0f8f 0000 0000     jpnz    0
-                       dc: R_ARC_32_ME text_label
+                       dc: R_ARC_32_ME .text
   e0:  2020 0f80 0000 0000     j       0
                        e4: R_ARC_32_ME external_text_label
   e8:  20a0 0000               j       0
index 38770f227095ac43b46b1e1da6da25ef82d37701..ac0c7e7891a7c24e73ea51ea0263de417c29fe52 100644 (file)
@@ -7,8 +7,8 @@ Disassembly of section .text:
 
 [0-9a-f]+ <text_label>:
    0:  2022 0f80 0000 0000     jl      0
-                       4: R_ARC_32_ME  text_label
+                       4: R_ARC_32_ME  .text
    8:  20e3 0042               jlne.d  \[r1\]
    c:  78e0                    nop_s
    e:  20e2 0f80 0000 0000     jl      0
-                       12: R_ARC_32_ME text_label
+                       12: R_ARC_32_ME .text
index 3d6d74e9d4eb54dfa627fd585919f76b1b4593da..3a9da7c9fec615863b4529905dde47c1ae7de3ec 100644 (file)
@@ -9,5 +9,5 @@ Disassembly of section .text:
 00000000 <.text>:
    0:  78e0                    nop_s
    2:  240a 0f80 0000 0000     mov     r4,0
-                       6: R_ARC_32_ME  .LC2
+                       6: R_ARC_32_ME  .rodata
    a:  78e0                    nop_s
index b32934512cc871d3918b73e86ee2a5b76afa8acd..4e2ebba7b6f52b1ce72c8b874f40fc62716a8996 100644 (file)
@@ -5,7 +5,7 @@
 
 Disassembly of section .text:
 
-[0-9a-f]+ <.L1-0x40>:
+[0-9a-f]+ <.text>:
    0:  1a00 0040               st      r1,\[r2\]
    4:  1a0e 0040               st      r1,\[r2,14\]
    8:  1a00 0042               stb     r1,\[r2\]
@@ -20,9 +20,7 @@ Disassembly of section .text:
   30:  1a03 0068               st.di.aw        r1,\[r2,3\]
   34:  1a04 006c               st[hw]+.di.aw   r1,\[r2,4\]
   38:  1c04 1f80 0000 0000     st      0,\[r12,4\]
-                       3c: R_ARC_32_ME .L1
-
-[0-9a-f]+ <.L1>:
+                       3c: R_ARC_32_ME .text\+0x40
   40:  212b 0080               sr      r1,\[r2\]
   44:  216b 0380               sr      r1,\[0xe\]
   48:  262b 7040 0000 03e8     sr      0x3e8,\[r1\]
index e24a457e49c422d69ee2829ad7ca6d649d0c8fac..32db828b71ff699c7df5d41103b86347b7b27073 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-29 Cupertino Miranda  <cmiranda@synopsys.com>
+
+       * testsuite/ld-elf/merge.d: Removed xfail for ARC.
+       * testsuite/ld-elf/merge2.d: Likewise.
+       * testsuite/ld-elf/merge3.d: Likewise.
+
 2016-02-29  Cupertino Miranda  <Cupertino.Miranda@synopsys.com>
 
        * scripttempl/arclinux.sc: Force .tdata and .tbss to always be
index 450ee07ff60621acf0bb9c2ddabb0eebf27b6c5a..17f3c06dd3180be3314261a1fdcc6c20f728ba18 100644 (file)
@@ -1,7 +1,7 @@
 #source: merge.s
 #ld: -T merge.ld
 #objdump: -s
-#xfail: "arc-*-*" "avr-*-*" "bfin-*-*" "cr16-*-*" "cris*-*-*" "crx-*-*" "d10v-*-*" "d30v-*-*"
+#xfail: "avr-*-*" "bfin-*-*" "cr16-*-*" "cris*-*-*" "crx-*-*" "d10v-*-*" "d30v-*-*"
 #xfail: "dlx-*-*" "fr30-*-*" "frv-*-*" "hppa*64*-*-*" "h8300-*-*" "score-*-*"
 #xfail: "i370-*-*" "i860-*-*" "i960-*-*" "ip2k-*-*" "iq2000-*-*" "lm32-*-*"
 #xfail: "mcore-*-*" "mn102*-*-*" "ms1-*-*" "mep-*-*"
index f7a18d66710116a939d53dd2740c6bb5b5eb0966..e5f887d741b42649bf97d567c63dea3ea37f1aa5 100644 (file)
@@ -1,7 +1,7 @@
 #source: merge2.s
 #ld: -T merge.ld
 #objdump: -s
-#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "hppa64-*-*"
+#xfail: "d30v-*-*" "dlx-*-*" "hppa64-*-*"
 #xfail: "i960-*-*" "ip2k-*-*" "pj-*-*"
 
 .*:     file format .*elf.*
index c595135d356ba164d04b3f18563654899553b0e7..a14ee2511c96633f29a3762e6c92e7461aa82a27 100644 (file)
@@ -1,7 +1,7 @@
 #source: merge3.s
 #ld: -T merge.ld
 #objdump: -s
-#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "hppa64-*-*"
+#xfail: "d30v-*-*" "dlx-*-*" "hppa64-*-*"
 #xfail: "i960-*-*" "ip2k-*-*" "pj-*-*"
 
 .*:     file format .*elf.*
This page took 0.040655 seconds and 4 git commands to generate.