diff --git a/lib/Input/Input.cpp b/lib/Input/Input.cpp index 1d7710b98..65e22b04f 100644 --- a/lib/Input/Input.cpp +++ b/lib/Input/Input.cpp @@ -102,11 +102,6 @@ bool Input::resolvePath(const LinkerConfig &PConfig) { } if (Type == Input::Script) { - if (PSearchDirs.hasSysRoot() && - (FileName.size() > 0 && FileName[0] == '/')) { - ResolvedPath = PSearchDirs.sysroot(); - ResolvedPath->append(FileName); - } if (!llvm::sys::fs::exists(ResolvedPath->native())) { const sys::fs::Path *P = PSearchDirs.find(FileName, Input::Script); if (P != nullptr) diff --git a/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/1.c b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/1.c new file mode 100644 index 000000000..8beef3e26 --- /dev/null +++ b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/1.c @@ -0,0 +1,4 @@ +// Simple library with exported functions +int exported_func_v1() { return 1; } +int exported_func_v2() { return 2; } +int hidden_func() { return 3; } diff --git a/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/dynamic.list b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/dynamic.list new file mode 100644 index 000000000..71ffea02b --- /dev/null +++ b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/dynamic.list @@ -0,0 +1,4 @@ +{ + exported_func_v1; + exported_func_v2; +}; diff --git a/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/version.script b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/version.script new file mode 100644 index 000000000..a19e54f43 --- /dev/null +++ b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/Inputs/version.script @@ -0,0 +1,6 @@ +{ + global: + exported_func_v1; + local: + *; +}; diff --git a/test/Common/standalone/sysRoot/VersionAndDynamicScripts/VersionAndDynamicScriptAbsolutePath.test b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/VersionAndDynamicScriptAbsolutePath.test new file mode 100644 index 000000000..a74642c87 --- /dev/null +++ b/test/Common/standalone/sysRoot/VersionAndDynamicScripts/VersionAndDynamicScriptAbsolutePath.test @@ -0,0 +1,44 @@ +#---VersionAndDynamicScripts.test---- sysRoot ----------------# + +#BEGIN_COMMENT +# Test that the version scripts and dynamic lists paths are properly handled +# when sysroot is used. +#END_COMMENT +#START_TEST +RUN: %clang %clangopts -o %t1.1.o %p/Inputs/1.c -c +RUN: %rm -rf %t1.sysroot %t1.dir +RUN: %mkdir %t.sysroot +RUN: %link %linkopts -o %t1.lib1.so %t1.1.o -shared --sysroot=%t.sysroot -L=/ \ +RUN: --version-script=%p/Inputs/version.script --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix VersionScriptAbs +RUN: %link %linkopts -o %t1.lib2.so %t1.1.o -shared --sysroot=%t.sysroot -L=/ \ +RUN: --dynamic-list=%p/Inputs/dynamic.list --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix DynScriptAbs +RUN: %mkdir %t1.dir +RUN: cd %t1.dir +RUN: %link %linkopts -o %t1.lib1.so %t1.1.o -shared --sysroot=%p/Inputs -L=/ \ +RUN: --version-script=version.script --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix VersionScriptSysRoot +RUN: %link %linkopts -o %t1.lib2.so %t1.1.o -shared --sysroot=%p/Inputs -L=/ \ +RUN: --dynamic-list=dynamic.list --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix DynScriptSysRoot +RUN: cp %p/Inputs/version.script version.script +RUN: cp %p/Inputs/dynamic.list dynamic.list +RUN: %link %linkopts -o %t1.lib1.so %t1.1.o -shared --sysroot=%p/Inputs -L=/ \ +RUN: --version-script=version.script --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix VersionScriptRel +RUN: %link %linkopts -o %t1.lib2.so %t1.1.o -shared --sysroot=%p/Inputs -L=/ \ +RUN: --dynamic-list=dynamic.list --verbose 2>&1 \ +RUN: | %filecheck %s --check-prefix DynScriptSysRel +#END_TEST + +VersionScriptAbs: Verbose: Parsing version script + +DynScriptAbs: Verbose: Dynamic List[{{.*}}] : exported_func_v1 +DynScriptAbs: Verbose: Dynamic List[{{.*}}] : exported_func_v2 + +VersionScriptSysRoot: Verbose: Trying to open input `{{.*}}/Inputs//version.script' of type `linker script' for namespec `version.script': found +DynScriptSysRoot: Verbose: Trying to open input `{{.*}}/Inputs//dynamic.list' of type `linker script' for namespec `dynamic.list': found + +VersionScriptRel: Verbose: Mapping input file 'version.script' into memory +DynScriptSysRel: Verbose: Mapping input file 'dynamic.list' into memory