<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86369>86369</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lld] why does lld export hidden symbols without warning?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Zhenhang1213
</td>
</tr>
</table>
<pre>
When I compile .o with two c files -fvisibility=hidden,and a.c depends on a function of b.c. then generates bit dynamic libraries of a.c, Finally define a main function in the new file to generate executable files together, there will be an error using ld, but not lld.
code:
a.c:
`#include<stdio.h>
#include"app.h"
int main1(void) {
printf("main1\n");
return 0;
}
`
a.h:
`int main1(void);`
b.c:
`#include<stdio.h>
#include"app.h"
extern int main1();
int shared1(void) {
printf("shared1\n");
main1();
return 0;
}
`
main.c:
`int main(void) {
return 0;
}
`
and the compiler Commands is:
```
clang -fvisibility=hidden -o a.o -c a.c
clang -fvisibility=hidden -o main.o -c main.c
clang -fvisibility=hidden -o b.o -c b.c
clang -shared -Wl,-soname,liba.so -o a.so a.o
clang -fuse-ld=lld -o main.out main.o b.o liba.so
```
error:
`/usr/bin/ld: main.out: hidden symbol `main1' in app.o is referenced by DSO
/usr/bin/ld: final link failed: bad valu`
without any error or warning:
clang -fuse-ld=lld -o main.out main.o b.o liba.so
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU2vqzYQ_TXOZhQEJgSyYPFu8pC66qKLJ3Vn4wlMa-zINsnNv68M5KvKla7UShEQfGbmzJkPhPfUGcSaFR-sOKzEGHrr6j97NL0wXcazfCWtuta_ejTwG7R2OJFGSCxcKPQQLhZaOJJGD-vjmTxJ0hSuLD_0pBQa9rNhH3tW7YVRIJIWFJ7QKA_WgIDjaNpA1oA9gkzaBEIM06FBJwJ6kBRAXY0YqAVN0glH6CNYJC3je2jICK2voPBIBkHAIMg8vJKJDsHgZaIIwd59A35iOwYh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