This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed/darwin]: Fix relocation addend for non-external relocs
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils at sourceware dot org
- Date: Tue, 9 Feb 2010 14:37:52 +0100
- Subject: [committed/darwin]: Fix relocation addend for non-external relocs
Hi,
a particularity of Mach-O is that even in object files sections do not overlap (only the first one is at
vma 0). And even relocations to non-external symbols have as an addend the offset of the section.
As this doesn't match bfd conventions, we need to adjust the addend.
Tested with gdb.
Tristan.
bfd/
2010-02-09 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Adjust addend for
non-external relocation.
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.53
diff -c -r1.53 mach-o.c
*** mach-o.c 8 Feb 2010 09:13:47 -0000 1.53
--- mach-o.c 9 Feb 2010 13:34:12 -0000
***************
*** 714,719 ****
--- 714,725 ----
+ /* For a symbol defined in section S, the addend (stored in the
+ binary) contains the address of the section. To comply with
+ bfd conventio, substract the section address.
+ Use the address from the header, so that the user can modify
+ the vma of the section. */
+ res->addend = -mdata->sections[num - 1]->addr;
reloc.r_extern = 0;
}
res->sym_ptr_ptr = sym;