[Nasm-bugs] [Bug 3392781] New: Local labels get emitted in object and break dead striping on macOS.
noreply-nasm at dev.nasm.us
noreply-nasm at dev.nasm.us
Thu Sep 2 17:28:36 PDT 2021
https://bugzilla.nasm.us/show_bug.cgi?id=3392781
Bug ID: 3392781
Summary: Local labels get emitted in object and break dead
striping on macOS.
Product: NASM
Version: 2.15.xx
Hardware: All
OS: Mac OS
Status: OPEN
Severity: normal
Priority: Medium
Component: Assembler
Assignee: nobody at nasm.us
Reporter: afish at apple.com
CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
hpa at zytor.com, nasm-bugs at nasm.us
Obtained from: Binary from nasm.us
I hit this issue again so I tracked down the owner of the macOS linker to get
more data...
Looks like I was wrong about what was happening in my older BZ. Turns out in
mach-O (and we think ELF too) the assembler does not emit local labels (1: etc)
into the object. Also for mach-O symbols starting with L (.L for ELF) don't get
emitted into the object by the assembler. In addition to this the machOS linker
skips labels starting with L when dead striping.
macOS example:
$ cat CopyMem.S
.globl _InternalMemCopyMem
_InternalMemCopyMem:
movq %rdi, %rax # rax <- Destination as return value
jae 0
cmpq %rdi, %r9
jmp L0
0:
L0:
ret
.subsystem_via_symbols
$ clang -c -o CopyMem.S.o CopyMem.S
$ nm -m CopyMem.S.o
0000000000000000 (__TEXT,__text) external _InternalMemCopyMem
Nasm does not strip local labels it name mangles them, and it also does not do
the assembly stripping for the L etc.
$ cat CopyMem.nasm
global _InternalMemCopyMem
_InternalMemCopyMem:
mov rax, rdi
jae .0
cmp r9, rdi
jmp L0
.0:
L0:
ret
%pragma macho subsections_via_symbols
$ nasm -f macho64 -o CopyMem.o CopyMem.nasm
$ nm -m CopyMem.o
0000000000000011 (__TEXT,__text) non-external L0
0000000000000000 (__TEXT,__text) external _InternalMemCopyMem
0000000000000011 (__TEXT,__text) non-external _InternalMemCopyMem.0
In my case the linker will deal with L0, but the _InternalMemCopyMem.0 causes
the `%pragma macho subsections_via_symbols` to strip out the end of the
function and boom.
I realize nasm has some features that may depend on the local name mangling so
I'd be OK if a flag was required to be more compatible with mach-O and ELF
assemblers in regards to assembler-stripped symbols. Just leaving them out of
the object file would make the code more compatible.
--
You are receiving this mail because:
You are watching all bug changes.
You are on the CC list for the bug.
More information about the Nasm-bugs
mailing list