<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - ObjC relocation against symbol in discarded section error on Windows using gnustep-2.0 runtime"
href="https://bugs.llvm.org/show_bug.cgi?id=49681">49681</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ObjC relocation against symbol in discarded section error on Windows using gnustep-2.0 runtime
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>frederik@algoriddim.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$SEL
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CLS
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CLS
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CLR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CLR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CAT
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CAT
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$PCL
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$PCL
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$PCR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$PCR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$CAL
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$CAL
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__start_.objcrt$STR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
lld-link: error: relocation against symbol in discarded section:
__stop.objcrt$STR
<span class="quote">>>> referenced by test-ffaa49.o:(.objc_init)</span >
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>