Skip to content

[RISC-V] Shoudn't linker GC get rid of the unused section? #118060

@futog

Description

@futog
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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions