Files
clang-p2996/lld/test/MachO/invalid/dso-handle-duplicate.s
Jez Ng d8283d9ddc [lld-macho][nfc] Give every SyntheticSection a fake InputSection
Previously, it was difficult to write code that handled both synthetic
and regular sections generically. We solve this problem by creating a
fake InputSection at the start of every SyntheticSection.

This refactor allows us to handle DSOHandle like a regular Defined
symbol (since Defined symbols must be attached to an InputSection), and
paves the way for supporting `__mh_*header` symbols. Additionally, it
simplifies our binding/rebase code.

I did have to extend Defined a little -- it now has a `linkerInternal`
flag, to indicate that `___dso_handle` should not be in the final symbol
table.

I've also added some additional testing for `___dso_handle`.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D98545
2021-03-12 17:26:27 -05:00

23 lines
758 B
ArmAsm

# REQUIRES: x86
## If for some bizarre reason the input file defines its own ___dso_handle, we
## should raise an error. At least, we've implemented this behavior if the
## conflicting symbol is a global. A local symbol of the same name will still
## take priority in our implementation, unlike in ld64. But that's a pretty
## far-out edge case that should be safe to ignore.
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: not %lld -dylib %t.o -o /dev/null 2>&1 | FileCheck %s -DFILE=%t.o
# CHECK: error: duplicate symbol: ___dso_handle
# CHECK-NEXT: >>> defined in [[FILE]]
# CHECK-NEXT: >>> defined in <internal>
.globl _main, ___dso_handle
.text
_main:
leaq ___dso_handle(%rip), %rdx
ret
___dso_handle:
.space 1