public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Iain Sandoe <developer@sandoe-acoustics.co.uk>
To: binutils Development <binutils@sourceware.org>
Cc: Tristan Gingold <gingold@adacore.com>
Subject: [Patch mach-o/bfd/gas] handle ABS indirect_symbols.
Date: Thu, 12 Jan 2012 18:29:00 -0000	[thread overview]
Message-ID: <79D2A42E-1056-4ED2-B0C2-7E097C3844AE@sandoe-acoustics.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]

a minor update to handle ABS symbols in the indirect symbol table.
tests attached

OK?
Iain

bfd:

	* mach-o.c (bfd_mach_o_build_dysymtab_command): Handle ABS symbols.

gas:

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

  bfd/mach-o.c           |    3 +++
  gas/config/obj-macho.c |   10 +++++++---
  2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index c519663..0846fe6 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -2199,6 +2199,9 @@ 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)
+		        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;
  		    }
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 61e6771..c381dbe 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -1545,14 +1545,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 ...  */



[-- Attachment #2: 12011218-dysym-abs-test.txt --]
[-- Type: text/plain, Size: 1960 bytes --]

 gas/testsuite/gas/mach-o/dysymtab-3.d |   22 ++++++++++++++++++++++
 gas/testsuite/gas/mach-o/symbols-7.s  |   27 +++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/gas/testsuite/gas/mach-o/dysymtab-3.d b/gas/testsuite/gas/mach-o/dysymtab-3.d
new file mode 100644
index 0000000..b2bf2b2
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/dysymtab-3.d
@@ -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: 0x00000168  num: 4( )+\(endoff: 0x00000178\)
+( )+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:
+( )+0000000000000000( )+0: 0xc0000000 LOCAL ABSOLUTE
+( )+0000000000000004( )+1: 0x80000000 LOCAL
+( )+0000000000000008( )+2: 0xc0000000 LOCAL ABSOLUTE
+( )+000000000000000c( )+3: 0xc0000000 LOCAL ABSOLUTE
diff --git a/gas/testsuite/gas/mach-o/symbols-7.s b/gas/testsuite/gas/mach-o/symbols-7.s
new file mode 100644
index 0000000..a4ffb66
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/symbols-7.s
@@ -0,0 +1,27 @@
+
+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
+	
+	
+	
\ No newline at end of file

[-- Attachment #3: Type: text/plain, Size: 3 bytes --]





             reply	other threads:[~2012-01-12 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 18:29 Iain Sandoe [this message]
2012-01-13  8:17 ` Tristan Gingold
2012-01-13 13:12   ` Iain Sandoe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79D2A42E-1056-4ED2-B0C2-7E097C3844AE@sandoe-acoustics.co.uk \
    --to=developer@sandoe-acoustics.co.uk \
    --cc=binutils@sourceware.org \
    --cc=gingold@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).