[llvm-dev] Need help on identifying a patch which fixed lld on linux platform

karnajit wangkhem via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 12 23:59:58 PDT 2019

Hi All,

This test is on a ubuntu 12 box. Can anyone please point me what
revision/commit-id of lld fixed this issue which was atleast in llvm 5.0.
├── build.sh
├── main.c
├── shared
│   └── sh.c
└── static
    └── st.c

[[ build.sh ]]


CFLAGS="-g -O"

rm shared/sh.o static/st.o main.o
rm shared/libsh.so static/libst.a main

${CC} ${CFLAGS} -c shared/sh.c -o shared/sh.o
${CC} ${CFLAGS} ${LDFLAGS} -shared -o shared/libsh.so shared/sh.o

${CC} ${CFLAGS} -c static/st.c -o static/st.o
${AR} cq static/libst.a static/st.o

${CC} ${CFLAGS} -c main.c -o main.o

${CC} ${CFLAGS} ${LDFLAGS} -o main -Lshared -lsh -Lstatic -lst  main.o

[[ main.c ]]

void gn();

int main()
    return 0;

[[ shared/sh.c ]]

#include <stdio.h>

void gn(void);
void fn(void);

void gn()
    printf("Calling gn...\n");

[[ static/st.c ]]

#include <stdio.h>

void fn(void);

void fn()
    printf("Calling fn...\n");

Code flow:
main -> gn (shared library) -> fn (part of the static lib)

With llvm 5.0

Calling gn...
./main: symbol lookup error: shared/libsh.so: undefined symbol: fn   <==
symbol fn was not found in binary "main"

readelf -s main | grep fn

With llvm 7.0

Calling gn...
Calling fn...

readelf -s main | grep fn
     9: 0000000000001100    12 FUNC    GLOBAL DEFAULT   13 fn
    36: 0000000000001100    12 FUNC    GLOBAL DEFAULT   13 fn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190613/5cc32aba/attachment.html>

More information about the llvm-dev mailing list