Minimal test
hello
Exit code 0
-----------------------
PIC in main that isn't dynamic
hello
Exit code 0
-----------------------
Minimal test of dynamic case
./testcase1
Got 1 args; argv[0] = ./testcase1
hello, world
hi there
retVal is 13
symbol found near *printf_call is myprint
Exit code 0
-----------------------
Multiple dynamic case
./testcase2
./nosuch.so: cannot open shared object file: No such file or directory
An open error should have been printed above

undefined symbol: dynLoadedEntryPoint
A search error should have been printed above

./testcase2a.so: undefined symbol: noSuchName
A search error should have been printed above

the value passed to dynLoadedEntryPoint is = 0
...got back rc=1 from dynLoadedEntryPoint
the value passed to dynLoadedEntryPoint is = 1
...got back rc=1 from dynLoadedEntryPoint
the value passed to dynLoadedEntryPoint is = 0
...got back rc=2 from second dynLoadedEntryPoint
the value passed to dynLoadedEntryPoint is = 1
...got back rc=2 from second dynLoadedEntryPoint
Exit code 0
-----------------------
Test ld.so as command; arg passing (can fail randomly; see comments)
../ld.so ./testcase1 xxx
Got 2 args; argv[0] = ./testcase1
            argv[1] = xxx
hello, world
hi there
retVal is 13
symbol found near *printf_call is myprint
Exit code 0
-----------------------
ld.so as command, --verify
../ld.so --verify ./testcase1
Exit code 0
-----------------------
ld.so as command, --list
../ld.so --list ./testcase1
	libc.so.version (0xxxxxxxxx)
	libc.so.version (0xxxxxxxxx)
	 => ../ld.so (0xxxxxxxxx)
Exit code 0
-----------------------
ld.so as command, --list with arg
../ld.so --list ./testcase1 fprintf
	libc.so.version (0xxxxxxxxx)
	libc.so.version (0xxxxxxxxx)
	 => ../ld.so (0xxxxxxxxx)
fprintf found at 0xxxxxxxxx in object at 0xxxxxxxxx
Exit code 0
-----------------------
ld.so as command on non-shared executable
../ld.so ./a.out
./a.out: error in loading shared libraries
./a.out: not a shared library
Exit code 127
-----------------------
ld.so as command --verify on non-shared executable
../ld.so --verify ./a.out
Exit code 1
-----------------------
ld.so with no args
../ld.so
Usage: ld.so [--list|--verify] EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]

You have invoked `ld.so', the helper program for shared library executables.
This program usually lives in `/usr/lib/ld.so', and special directives
in executable files using shared libraries tell the program loader
to load the helper program from this file.  This helper program loads
the shared libraries needed by the program executable, prepares the program
to run, and runs it.  You may invoke this helper program directly from the
command line to load and run an executable file; this is like executing
that file itself, but always uses this helper program from the file you
specified, instead of the helper program file specified in the executable
file you run.  The --list option lists all required shared libraries,
and --verify verifies that the program can be successfully executed.

This is mostly of use for maintainers to test new versions of this
helper program; chances are you did not intend to run this program.
Exit code 127
-----------------------
Test LD_TRACE_LOADED_OBJECTS
LD_TRACE_LOADED_OBJECTS=1 ./testcase2
	libc.so.version (0xxxxxxxxx)
	libc.so.version (0xxxxxxxxx)
	../ld.so => ../ld.so (0xxxxxxxxx)
Exit code 0
-----------------------
Test error when lib not found
./testcase3
./testcase3: error in loading shared libraries
libtest1.so: cannot open shared object file: No such file or directory
Exit code 127
-----------------------
Test LD_LIBRARY_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./testcase3
starting main
init global var is 0x0 0xb0 0x0 0xd0 0x0
global var is 0xa1 0xb1 0xc1 0xd1 0xe1
foo called
foo's result is 31415926
global var is 0xa2 0xb2 0xc2 0xd2 0xe2
foo called
got to withmain()
thisisalongname's result is 21713
global var is 0xa3 0xb3 0xc3 0xd3 0xe3
A random number 
Exit code 0
-----------------------
Test whether PIC in main works
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./testcase3pic
starting main
init global var is 0x0 0xb0 0x0 0xd0 0x0
global var is 0xa1 0xb1 0xc1 0xd1 0xe1
foo called
foo's result is 31415926
global var is 0xa2 0xb2 0xc2 0xd2 0xe2
foo called
got to withmain()
thisisalongname's result is 21713
global var is 0xa3 0xb3 0xc3 0xd3 0xe3
A random number 
Exit code 0
-----------------------
Test whether LD_BIND_NOW works
LD_BIND_NOW=1 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./testcase3pic
starting main
init global var is 0x0 0xb0 0x0 0xd0 0x0
global var is 0xa1 0xb1 0xc1 0xd1 0xe1
foo called
foo's result is 31415926
global var is 0xa2 0xb2 0xc2 0xd2 0xe2
foo called
got to withmain()
thisisalongname's result is 21713
global var is 0xa3 0xb3 0xc3 0xd3 0xe3
A random number 
Exit code 0
-----------------------
Test whether lazy binding is lazy
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:bogus ./testcase3pic
starting main
init global var is 0x0 0xb0 0x0 0xd0 0x0
global var is 0xa1 0xb1 0xc1 0xd1 0xe1
foo called
foo's result is 31415926
global var is 0xa2 0xb2 0xc2 0xd2 0xe2
foo called
got to withmain()
thisisalongname's result is 21713
global var is 0xa3 0xb3 0xc3 0xd3 0xe3
./testcase3pic: error in loading shared libraries
: undefined symbol: callrand
Exit code 127
-----------------------
Test whether LD_BIND_NOW fails as expected
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:bogus LD_BIND_NOW=1 ./testcase3
./testcase3: error in loading shared libraries
: undefined symbol: callrand
Exit code 0
-----------------------
Test that leaf only and data only shared libs work
testcase4
simple leaf: 123456
cross access: 654321
global: 567890
Exit code 0
-----------------------
Test that fortran main and basic shared libs work
Hello world from g77
  -- FYI, sin( 3.000) is  0.14112
-----------------------
Test that fortran PIC main and basic shared libs work
Hello world from g77
  -- FYI, sin( 3.000) is  0.14112
Exit code 0
-----------------------
Fortran as a shared lib
a  is    111
b1 is    999
c1 is  11111
c2 is  22222
In sub:
a  is    111
b1 is    999
c1 is  11111
c2 is  22222
Exit code 0
-----------------------
Fortran common when .so loaded before .o
a  is    111
b1 is    999
c1 is  11111
c2 is  22222
In sub:
a  is    111
b1 is    999
c1 is  11111
c2 is  22222
Exit code 0
-----------------------
C++ with class crossing between shared lib and main
mybox's volume: 6, front: 2
From sub:
mainbox's volume: 120, front: 20
subbox's volume: 24, front: 6
From Main:
mainbox's volume: 120, front: 20
subbox's volume: 24, front: 6
Exit code 0
-----------------------
Reversed load, C++
mybox's volume: 6, front: 2
From sub:
mainbox's volume: 120, front: 20
subbox's volume: 24, front: 6
From Main:
mainbox's volume: 120, front: 20
subbox's volume: 24, front: 6
Exit code 0
-----------------------
Function pointers, duplicate name masking, and symbolic name hiding
Lib1 called
Lib2 called
Lib3 called
Func #1 called
Func #3 called
Exit code 0
-----------------------
library chaining
Func #1 called
Func #2 called
Exit code 0
-----------------------
library locking
ld: fortliblock.so: Linking with this file is prohibited.

fortliblock.so: could not read symbols: Invalid operation
Exit code 1
-----------------------
weak symbols
strong() 1
strong_data[0] 1

from callweak() 3
from callweak(): _weak_data[0] 3

weak() 3
weak_data[0] 3
-----------------------
archive libdl
Got 1 args; argv[0] = ./artestcase
retVal is 123456
symbol found near *printf_call is mytest
