<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118060>118060</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V] Shoudn't linker GC get rid of the unused section?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
futog
</td>
</tr>
</table>
<pre>
```
lib.h:
void throw_with_try_catch();
void fun();
lib.cpp:
void undefined();
void throw_with_try_catch() {
try {
throw 1;
} catch(int) {}
undefined();
}
void fun() {}
```
lib.o: compiled with `-ffunction-sections -fdata-sections`
```
main.cpp:
#include "lib.h"
int main() {
fun();
}
```
clang main.cpp -o main lib.o -Wl,--gc-sections -mno-relax:
**`ld.lld: error: undefined symbol: undefined()`**
Is this the expected behavior?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU09v4y4Q_TT4MnIEOP538CFtlJ96_VXaPVbYjG12MUSA0-bbr3DcNkm3WguZMTBv3ntjhPdqMIgNyR9Ivk_EHEbrmn4OdkhaK88NAJCCroPuQKt2M5JsF-PLc7JKQhidfX15VWF8Ce780onQjYRXhNcke7g728_mfmudInh3PH6Fn43EXhmU3yT-mwaQ8ooHAAR3fl9bsoDdMI3Y5R7eEZQJ7yDl_kttgG8Y_u3wrQefkDc233piSbaDzk5HpVFClBebkvb9bLqgrEk9LrOHtJciiI_vG7T7ApNQ5spuwjNlOj1LBML5pc-cf6GvTFgyv7H1vrmrtqvqV3CdFmb44AGpXeKLZEh_asIf03ToruRNxqYOtXj7_EcI38VRUC03WstoFTpnXQw-ugL-PLVW36ytPAu6Iiw0nzyEUcUXAr4dsQsoocVRnFSEPCSyyWSd1SLBhpUZr4q8qvJkbMpqm8m-ZpQKtkXW1tWW5VsmyqKTKBlNVMMp3zLGa1pmFc03ec2wLHmFRdtVLM_JluIklN5ofZo21g2J8n7GhrGKFjTRokXtl5vKucFXWHZji_J94pqYlLbz4MmWauWD_4QJKujliv__9PyY_iD5Hp5HO0tDeBlAK_MbHfz3CAMGcEqC7Rf5s5l9dO5iftQ-O92MIRx9dJ8fCD8MKoxzu-nsRPghFlyn9OjsL-wC4YeFpif8sOo4NfxPAAAA__9EwUGE">