Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SymbolResolver/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ LDSymbol *IRBuilder::addSymbolFromDynObj(
Input.setNeeded();
NP.addSharedLibSymbol(InputSym);
}
if (ResolvedResult.Overriden && ResolvedResult.Existent) {
if (ResolvedResult.Overriden && ResolvedResult.Info->outSymbol()) {
ResolvedResult.Info->setOutSymbol(InputSym);
}
// If the symbol is from dynamic library and we are not making a dynamic
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int foo() { return 1; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int foo();
int bar() { return 3; }
int baz() { return foo(); }

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int main() { return 0; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#---UnneededSharedLibReference.test-------------------- Executable, LS -------#
#BEGIN_COMMENT
# Validates that with --as-needed we do not add DT_NEEDED entries for libraries
# that are referenced only by an unneeded shared library.
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -o %t1.1.o %p/Inputs/1.c -c -ffunction-sections
RUN: %clang %clangopts -o %t1.2.o %p/Inputs/2.c -c -ffunction-sections
RUN: %clang %clangopts -o %t1.main.o %p/Inputs/main.c -c -ffunction-sections
RUN: %link %linkopts -o %t1.lib1.so -shared %t1.1.o
RUN: %link %linkopts -o %t1.lib2.so -shared %t1.2.o
RUN: %link %linkopts -o %t1.out %t1.main.o --as-needed %t1.lib2.so %t1.lib1.so
RUN: %readelf --dynamic %t1.out 2>&1 | %filecheck %s --check-prefix=DYN
#END_TEST
DYN-NOT: lib2.so
DYN-NOT: lib1.so
Loading