[Nasm-bugs] [Bug 3392469] New: mach-o executables crash with dead striping due to missing object relocations.

no-reply at bugzilla-nasm.gorcunov.org no-reply at bugzilla-nasm.gorcunov.org
Thu Mar 1 10:41:58 PST 2018


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

            Bug ID: 3392469
           Summary: mach-o executables crash with dead striping due to
                    missing object relocations.
           Product: NASM
           Version: 2.13.xx
          Hardware: Macintosh
                OS: All
            Status: OPEN
          Severity: severe
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: afish at apple.com
                CC: gorcunov at gmail.com, hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: Binary from nasm.us

Created attachment 411628
  --> https://bugzilla.nasm.us/attachment.cgi?id=411628&action=edit
NASM File that fails.

If one assembly function calls another assembly function in a file via a
relative instruction there needs to be a relocation in the object (mach-O seems
to use GENERIC_RELOC_VANILLA).

Example:
Function A:
Function B:
Function C:
  Calls A

When Function B gets dead stripped the relative offset from C() to A() changes
and needs to get fixed up by the linker. This causes the Xcode linker to dead
strip function A in error. 

Steps To Reproduce:
clang -arch i386 IoFifoSevS.S -c IoFifoSevS.o
nasm -f macho32  -o IoFifoSev.o  IoFifoSev.nasm 
clang -arch i386 IoFifoSev.o  main.c -dead_strip

lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (i386).
(lldb) dis -b -n  IoReadFifo8
a.out`IoReadFifo8:
a.out[0x1f90] <+0>:  57              pushl  %edi
a.out[0x1f91] <+1>:  e8 e8 ff ff ff  calll  0x1f7e                    ;
_mh_execute_header + 3966
a.out[0x1f96] <+6>:  85 c0           testl  %eax, %eax
a.out[0x1f98] <+8>:  5f              popl   %edi
a.out[0x1f99] <+9>:  c3              retl   
a.out[0x1f9a] <+10>: 90              nop    
a.out[0x1f9b] <+11>: 90              nop    
a.out[0x1f9c] <+12>: 90              nop    
a.out[0x1f9d] <+13>: 90              nop    
a.out[0x1f9e] <+14>: 90              nop    
a.out[0x1f9f] <+15>: 90              nop    

# clang assembler example for reference. 
clang -arch i386 IoFifoSevS.S -c IoFifoSevS.o
clang -arch i386 IoFifoSevS.o  main.c -dead_strip

otool -rv IoFifoSevS.o
RELOCATION RECORDS FOR [__text]:
00000014 GENERIC_RELOC_VANILLA __text
0000000b GENERIC_RELOC_VANILLA __text
otool -rv IoFifoSev.o

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