| Issue |
243305
|
| Summary |
[lld][MachO] ld64.lld asserts "ARM32 arch is not supported" on N_ARM_THUMB_DEF in a 64-bit object
|
| Labels |
lld:MachO,
crash
|
| Assignees |
|
| Reporter |
AnantaSrikar
|
`createDefined` asserts that a defined symbol doesn't have `N_ARM_THUMB_DEF` (`n_desc` bit `0x8`). That bit comes from the input, so an ARM64 or x86-64 object that sets it aborts an assertions build. Builds without assertions ignore the bit and link the object.
**Version**: main at c7014922f582 (2026-11-16), built from the Git repository with `-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS=lld`, on x86_64 Linux.
### Reproducer
```sh
cat > thumb.yaml <<'YAML'
--- !mach-o
IsLittleEndian: true
FileHeader:
magic: 0xFEEDFACF
cputype: 0x100000C
cpusubtype: 0x0
filetype: 0x1
ncmds: 2
sizeofcmds: 176
flags: 0x0
reserved: 0x0
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: ''
vmaddr: 0
vmsize: 9
fileoff: 208
filesize: 9
maxprot: 7
initprot: 7
nsects: 1
flags: 0
Sections:
- sectname: __text
segname: __TEXT
addr: 0x0
size: 9
offset: 0xD0
align: 2
reloff: 0xE0
nreloc: 1
flags: 0x80000400
reserved1: 0x0
reserved2: 0x0
reserved3: 0x0
content: 00000094C0035FD600
relocations:
- address: 0x0
symbolnum: 1
pcrel: true
length: 2
extern: true
type: 2
scattered: false
value: 0
- cmd: LC_SYMTAB
cmdsize: 24
symoff: 232
nsyms: 2
stroff: 264
strsize: 34
LinkEditData:
NameList:
- n_strx: 1
n_type: 0xF
n_sect: 1
n_desc: 8
n_value: 0
- n_strx: 17
n_type: 0x1
n_sect: 0
n_desc: 0
n_value: 0
StringTable:
- ''
- _entry_00000000
- _target_00000000
...
YAML
yaml2obj thumb.yaml -o thumb.o
ld64.lld -arch arm64 -platform_version macos 11.0 11.0 -dylib -undefined dynamic_lookup -o thumb.dylib thumb.o
```
The defined symbol's `n_desc` is `8`. With `0` instead, the same object links (status 0). The same change in an x86-64 object aborts the same way.
### Observed
```
ld64.lld: lld/MachO/InputFiles.cpp:734: macho::Symbol *createDefined(const NList &, StringRef, InputSection *, uint64_t, uint64_t, bool) [NList = lld::structs::nlist_64]: Assertion `!(sym.n_desc & N_ARM_THUMB_DEF) && "ARM32 arch is not supported"' failed.
```
```
void lld::macho::ObjFile::parseSymbols<lld::macho::LP64>(llvm::ArrayRef<lld::macho::LP64::section>, llvm::ArrayRef<lld::macho::LP64::nlist>, char const*, bool)
void lld::macho::ObjFile::parse<lld::macho::LP64>()
lld::macho::ObjFile::ObjFile(llvm::MemoryBufferRef, unsigned int, llvm::StringRef, bool, bool, bool, bool)
```
`createDefined` is inlined into `parseSymbols` in this build.
### Expected
Either ignore the flag, as builds without assertions do, or report an error for the input file.
### Analysis
https://github.com/llvm/llvm-project/blob/c7014922f5829426952a38d079220c21b0a8ebe8/lld/MachO/InputFiles.cpp#L731-L734
The assertion checks a property of the input rather than an internal invariant. LLD doesn't support ARM32 at all, so `N_ARM_THUMB_DEF` can only appear here in a malformed 64-bit object. Removing the assertion keeps today's release behavior; an error would be stricter.
This report was drafted with help from an AI assistant (Claude); I reviewed it and reproduced it myself.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs