[Nasm-bugs] [Bug 3392348] nasm 2.12.01 generates bad pc-relative relocations for macho32 target

no-reply at bugzilla-nasm.gorcunov.org no-reply at bugzilla-nasm.gorcunov.org
Mon May 9 10:53:29 PDT 2016


http://bugzilla.nasm.us/show_bug.cgi?id=3392348

--- Comment #4 from zenith432 at users.sourceforge.net ---
BTW, -- for hpa, in case you doubt....

Look at current revision of Apple's x86_64/reloc.c

http://opensource.apple.com//source/xnu/xnu-3248.20.55/EXTERNAL_HEADERS/mach-o/x86_64/reloc.h

At this comment...

 * The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does
 * not have RELA relocations).  For PC-relative relocations, the addend is
 * stored directly in the instruction.  This is different from other Mach-O
 * architectures, which encode the addend minus the current section offset.

So until x86_64, Apple always stored 'minus the offset' in the instruction. 
The reason this was changed in x86_64, is that the current offset may be > 2GB,
so storing 'minus the offset' may overflow the signed 32-bit addend.  So Apple
was forced to change the encoding by the immutable laws of mathematics.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list