blob: 2f5c0f48501f747d3054a7c44ac46ee5f3f755e0 [file] [log] [blame]
/*
XFAIL: win32
This test does not pass on Windows because a path starting with
"/" is not considered as an absolute path. (It needs a drive
letter.)
*/
/*
In general the linker scripts's GROUP command works like a pair
of command line options --start-group/--end-group. But there is
a difference in the files look up algorithm.
The --start-group/--end-group commands use a trivial approach:
a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so'
suffix and search the path through library search directories.
b) Otherwise, use the path 'as-is'.
The GROUP command implements more compicated approach:
a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so'
suffix and search the path through library search directories.
b) If the path does not have '-l' prefix, and sysroot is configured,
and the path starts with the / character, and the script being
processed is located inside the sysroot, search the path under
the sysroot. Otherwise, try to open the path in the current
directory. If it is not found, search through library search
directories.
*/
/*
This link should finish successfully. The --start-group/--end-group
contains an existing absolute path to the file.
RUN: lld -flavor gnu -target x86_64 -shared \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: --start-group %p/Inputs/shared.so-x86-64 --end-group -o %t1
*/
/*
This link should fail with unknown input file format error.
There is no shared.so-x86-64 file in the current directory.
RUN: not \
RUN: lld -flavor gnu -target x86_64 -shared \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: --start-group shared.so-x86-64 --end-group -o %t2
*/
/*
This link should fail with unknown input file format error.
The absolute path /shared.so-x86-64 does not exist and the linker
should not attempt to search it under the sysroot directory.
RUN: not \
RUN: lld -flavor gnu -target x86_64 -shared --sysroot=%p/Inputs \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: --start-group /shared.so-x86-64 --end-group -o %t3
*/
/*
This link should finish successfully. The group-cmd-search-1.ls
script contains "GROUP ( shared.so-x86-64 )" command and the linker
has to search shared.so-x86-64 through the library search paths.
RUN: lld -flavor gnu -target x86_64 -shared \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/group-cmd-search-1.ls -o %t4
*/
/*
This link should fail with unknown input file format error.
The group-cmd-search-2.ls script contains GROUP command with
a non-existing absolute path but there is no --sysroot argument.
RUN: not \
RUN: lld -flavor gnu -target x86_64 -shared \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/group-cmd-search-2.ls -o %t5
*/
/*
This link should finish successfully. The group-cmd-search-2.ls
script contains GROUP command with an absolute path and the sysroot
directory is provided. The linker has to search the absolute path
under the sysroot directory.
RUN: lld -flavor gnu -target x86_64 -shared --sysroot=%p/Inputs \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/group-cmd-search-2.ls -o %t6
*/
/*
This link should finish successfully. The group-cmd-search-2.ls
script contains GROUP command with an absolute path and the sysroot
directory is provided. The linker has to search the absolute path
under the sysroot directory.
RUN: lld -flavor gnu -target x86_64 -shared --sysroot=%p/Inputs/../Inputs \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/group-cmd-search-2.ls -o %t6
*/
/*
This link should finish successfully. The group-cmd-search-3.ls
script contains GROUP command with two elements. The first one
has a -l:<path> form and should be found by iterating through
lib dirs and searching the 'path' name exactly. The second element
has a -l<lib name> form and should be found by constructing a full
library name lib<lib name>.a and iterating through lib dirs.
RUN: lld -flavor gnu -target x86_64 -shared \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/group-cmd-search-3.ls -o %t8
*/
/*
This link should fail with unknown input file format error.
The linker script from this file contains GROUP with an absolute
path which can be found under provided sysroot directory.
But the linker script itself is not under the sysroot.
RUN: not \
RUN: lld -flavor gnu -target x86_64 -shared --sysroot=%p/Inputs \
RUN: -L%p/Inputs %p/Inputs/use-shared.x86-64 \
RUN: %s -o %t7
*/
GROUP ( /shared.so-x86-64 )