[Nasm-bugs] [Bug 3392496] Wrong relocation record for reference in .data

noreply-nasm at gorcunov.org noreply-nasm at gorcunov.org
Mon Jul 9 11:22:42 PDT 2018


https://bugzilla.nasm.us/show_bug.cgi?id=3392496

zenith432 at users.sourceforge.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|OPEN                        |CONFIRMED

--- Comment #1 from zenith432 at users.sourceforge.net ---
This is with -f macho64, and happens in 2.14rc15 too.

It's because of the following code in macho_output (output/outmacho.c)

    case OUT_ADDRESS:
...
                    add_reloc(s, section, addr, RL_ABS, asize);

Unlike the relative relocations, OUT_ADDRESS ignores the adjustments made by
add_reloc, and writes the offset of the target symbol in the target section. 
If the target symbol is in the same file, add_reloc emits an internal reloc for
the target section, and the offset written is the offset in the target section.
 If the target symbol is external, its offset is zero (or an explicit addend),
and add_reloc emits an external reloc for the symbol.

For macho64, add_reloc converts internal relocs to external relocs and outputs
an external reloc for the target symbol.  macho_output ignores this and
continues to write the offset of the target symbol in the target section. 
Instead, the offset of the symbol in the target section should be subtracted
leaving either zero or an explicit addend.

-- 
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