[llvm-bugs] [Bug 49681] New: ObjC relocation against symbol in discarded section error on Windows using gnustep-2.0 runtime
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 22 09:33:06 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49681
Bug ID: 49681
Summary: ObjC relocation against symbol in discarded section
error on Windows using gnustep-2.0 runtime
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: frederik at algoriddim.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Linking a file that references functions from the gnustep-2.0 runtime, but does
not reference any Objective-C code, results in the following linker errors when
using LLD:
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$SEL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$SEL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CLS
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CLS
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CLR
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CLR
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CAT
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CAT
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$PCL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$PCL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$PCR
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$PCR
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CAL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CAL
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$STR
>>> referenced by test-ffaa49.o:(.objc_init)
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$STR
>>> referenced by test-ffaa49.o:(.objc_init)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Using link.exe only results in the following warnings:
libcmt.lib(exe_main.obj) : warning LNK4078: multiple '.CRT' sections found with
different attributes (40400040)
libcmt.lib(initializers.obj) : warning LNK4254: section '.CRT' (C0000040)
merged into '.rdata' (40000040) with different attributes
This can be reproduced e.g. as follows:
$ cat test.m
#include <objc/runtime.h>
int main(int argc, char *argv[]) {
objc_getClass("Test");
}
$ clang -fobjc-runtime=gnustep-2.0 -fuse-ld=lld -lobjc test.m
Adding any code that references Objective-C classes in the same file, e.g.
`[NSObject new]`, makes the linker errors disappear. Likewise using the
gnustep-1.9 runtime does not expose this issue.
This is relevant when using Autoconf to check for the existence of runtime
functions, as it will generate files like the above (minus the #include) to do
so.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210322/7301b7ff/attachment-0001.html>
More information about the llvm-bugs
mailing list