[PATCH] D17252: [ELF, Bug 26360] - allows undefines that are referenced from garbage collected sections.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 23:39:15 PST 2016


grimar added a comment.

In http://reviews.llvm.org/D17252#352805, @rafael wrote:

> Is this really desirable?
>
> It looks like an optimization option changing the semantics. What do
>  you get with gold?
>
> Cheers,
> Rafael


Hi Rafael,

gold and ld has the same behavior and allows such undefines, I checked that first before started to implement the patch and it seems logical to me: if section is excluded it is no need to error the undefines from it.
Below is the how I got the sample for test cases and the results of linkage using 3 linkers:

main.cpp:

  void undefined_function();
  
  void unreferenced_function() {
    undefined_function();
  }
  
  int main(int argc, char **argv) {
    return 0;
  }

clang -ffunction-sections main.cpp -S -o main.s
llvm-mc -filetype=obj -triple=x86_64-pc-linux main.s -o main.o

ld -e main --gc-sections main.o -o test
(ok)

gold -e main --gc-sections main.o -o test
(ok)

ld.lld -e main --gc-sections main.o -o test
undefined symbol: _Z18undefined_functionv in main.o


http://reviews.llvm.org/D17252





More information about the llvm-commits mailing list