mirror of
https://github.com/rui314/mold.git
synced 2024-11-13 09:39:13 +03:00
[Mach-O] Report errors for remaining undefined symbols
This commit is contained in:
parent
04fcb66580
commit
7236d14650
@ -104,6 +104,11 @@ void InputSection::scan_relocations(Context &ctx) {
|
||||
|
||||
void Subsection::apply_reloc(Context &ctx, u8 *buf) {
|
||||
for (const Relocation &rel : std::span(isec.rels).subspan(rel_offset, nrels)) {
|
||||
if (rel.sym && !rel.sym->file) {
|
||||
Error(ctx) << "undefined symbol: " << isec.file << ": " << *rel.sym;
|
||||
continue;
|
||||
}
|
||||
|
||||
u32 *loc = (u32 *)(buf + rel.offset);
|
||||
|
||||
#define S (rel.sym ? rel.sym->get_addr(ctx) : \
|
||||
|
@ -205,6 +205,7 @@ int main(int argc, char **argv) {
|
||||
seg->copy_buf(ctx);
|
||||
|
||||
ctx.output_file->close(ctx);
|
||||
ctx.checkpoint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
20
test/macho/missing-error.sh
Executable file
20
test/macho/missing-error.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd $(dirname $0)
|
||||
mold=`pwd`/../../ld64.mold
|
||||
echo -n "Testing $(basename -s .sh $0) ... "
|
||||
t=$(pwd)/../../out/test/elf/$(basename -s .sh $0)
|
||||
mkdir -p $t
|
||||
|
||||
cat <<EOF | cc -o $t/a.o -c -xc -
|
||||
int foo();
|
||||
|
||||
int main() {
|
||||
foo();
|
||||
}
|
||||
EOF
|
||||
|
||||
! clang -fuse-ld=$mold -o $t/exe $t/a.o 2> $t/log || false
|
||||
grep -q 'undefined symbol: .*\.o: _foo' $t/log
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user