handle absolute indirect syms in mach-o
authorIain Sandoe <iain@codesourcery.com>
Fri, 13 Jan 2012 12:59:30 +0000 (12:59 +0000)
committerIain Sandoe <iain@codesourcery.com>
Fri, 13 Jan 2012 12:59:30 +0000 (12:59 +0000)
bfd:

* mach-o.c (bfd_mach_o_build_dysymtab_command): Handle absolute
indirect symbols.
gas:

* config/obj-macho.c (obj_mach_o_set_indirect_symbols): Handle
absolute indirect symbols.

gas/testsuite:

* gas/mach-o/dysymtab-3.d: New.
* gas/mach-o/symbols-7.s: New.

bfd/ChangeLog
bfd/mach-o.c
gas/ChangeLog
gas/config/obj-macho.c
gas/testsuite/ChangeLog
gas/testsuite/gas/mach-o/dysymtab-3.d [new file with mode: 0644]
gas/testsuite/gas/mach-o/symbols-7.s [new file with mode: 0644]

index 77749a7833bfdc171d0af96d95329b7d8370d45f..7b569678ec22535d901f5fdc2458f5f764c7addd 100644 (file)
@@ -1,6 +1,11 @@
 2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
 
-       * mach-o.c (bfd_mach_o_write_relocs): Move compuation of relocs file
+       * mach-o.c (bfd_mach_o_build_dysymtab_command): Handle absolute 
+       indirect symbols.  
+
+2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
+
+       * mach-o.c (bfd_mach_o_write_relocs): Move computation of relocs file
        position from here... to (bfd_mach_o_build_seg_command): Here.
 
 2012-01-12  Iain Sandoe  <idsandoe@googlemail.com>
index 262531970f5899b7fd64ac34cb3cf7a546f73214..a13ac4ea69dae7a7c32fa92efdea171cc7776b5f 100644 (file)
@@ -2210,6 +2210,10 @@ bfd_mach_o_build_dysymtab_command (bfd *abfd,
                    {
                      if (isyms[j] == NULL)
                        dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL;
+                     else if (isyms[j]->symbol.section == bfd_abs_section_ptr
+                              && ! (isyms[j]->n_type & BFD_MACH_O_N_EXT))
+                       dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL
+                                                | BFD_MACH_O_INDIRECT_SYM_ABS;
                      else
                        dsym->indirect_syms[n] = isyms[j]->symbol.udata.i;
                    }
index befc7bfd1353cc02457e8736ac56f4d3b40816c0..9d405565a7f8b1e946d06d29f9cf09c67abc9636 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
+
+       * config/obj-macho.c (obj_mach_o_set_indirect_symbols): Handle
+       absolute indirect symbols.
+
 2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
 
        * config/obj-macho.c (obj_mach_o_set_vma_data): New type.
index 988b098a1b7f961d9148aa8bc0febd3555eb736f..ddf098881b5d2aa8f3a67bedfc110304611592a1 100644 (file)
@@ -1630,14 +1630,18 @@ obj_mach_o_set_indirect_symbols (bfd *abfd, asection *sec,
              
              for (isym = list, n = 0; isym != NULL; isym = isym->next, n++)
                {
+                 sym = (bfd_mach_o_asymbol *)symbol_get_bfdsym (isym->sym);
                  /* Array is init to NULL & NULL signals a local symbol
                     If the section is lazy-bound, we need to keep the
-                    reference to the symbol, since dyld can override.  */
-                 if (S_IS_LOCAL (isym->sym) && ! lazy)
+                    reference to the symbol, since dyld can override.
+                    
+                    Absolute symbols are handled specially.  */
+                 if (sym->symbol.section == bfd_abs_section_ptr)
+                   ms->indirect_syms[n] = sym;
+                 else if (S_IS_LOCAL (isym->sym) && ! lazy)
                    ;
                  else
                    {
-                     sym = (bfd_mach_o_asymbol *)symbol_get_bfdsym (isym->sym);
                      if (sym == NULL)
                        ;
                      /* If the symbols is external ...  */
index cb0c64df44905df8d243b01a5572d0eba37a8854..01418cb3f14a925d97bbf085826b6962b0d08623 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
+
+       * gas/mach-o/dysymtab-3.d: New.
+       * gas/mach-o/symbols-7.s: New.
+
 2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
 
        * gas/mach-o/dysymtab-2.d: Update to include the set VMA.
diff --git a/gas/testsuite/gas/mach-o/dysymtab-3.d b/gas/testsuite/gas/mach-o/dysymtab-3.d
new file mode 100644 (file)
index 0000000..6d2430f
--- /dev/null
@@ -0,0 +1,22 @@
+#as: -L
+#objdump: -P dysymtab
+#target: i?86-*-darwin* powerpc-*-darwin*
+#source: symbols-7.s
+.*: +file format mach-o.*
+#...
+Load command dysymtab:
+( )+local symbols: idx:( )+0  num: 4( )+\(nxtidx: 4\)
+( )+external symbols: idx:( )+4  num: 1( )+\(nxtidx: 5\)
+( )+undefined symbols: idx:( )+5  num: 0( )+\(nxtidx: 5\)
+( )+table of content: off: 0x00000000  num: 0( )+\(endoff: 0x00000000\)
+( )+module table: off: 0x00000000  num: 0( )+\(endoff: 0x00000000\)
+( )+external reference table: off: 0x00000000  num: 0( )+\(endoff: 0x00000000\)
+( )+indirect symbol table: off: 0x00000170  num: 4( )+\(endoff: 0x00000180\)
+( )+external relocation table: off: 0x00000000  num: 0( )+\(endoff: 0x00000000\)
+( )+local relocation table: off: 0x00000000  num: 0( )+\(endoff: 0x00000000\)
+( )+indirect symbols:
+( )+for section __DATA.__nl_symbol_ptr:
+( )+0000000000000014( )+0: 0xc0000000 LOCAL ABSOLUTE
+( )+0000000000000018( )+1: 0x80000000 LOCAL
+( )+000000000000001c( )+2: 0xc0000000 LOCAL ABSOLUTE
+( )+0000000000000020( )+3: 0x00000004 c
diff --git a/gas/testsuite/gas/mach-o/symbols-7.s b/gas/testsuite/gas/mach-o/symbols-7.s
new file mode 100644 (file)
index 0000000..8df048d
--- /dev/null
@@ -0,0 +1,24 @@
+
+L01:   .space 10
+
+L02:   .space 10
+
+
+       .non_lazy_symbol_pointer
+       
+       a = 5
+       .indirect_symbol a
+       .space 4
+       
+       .indirect_symbol L01
+       .long L01-.
+       
+       .indirect_symbol b
+       .space 4
+       
+       b = 10
+       
+       .globl c
+       c = 20
+       .indirect_symbol c
+       .space 4