From 16c579d5fbb7ac62bf2f6f105d56d46e7409f74e Mon Sep 17 00:00:00 2001 From: John Ogness Date: Mon, 28 Jan 2019 19:42:15 +0106 Subject: linking: move text docs out of Makefile example The text docs are general references showing how to build, link, and verify dynamic libraries and executables. They are not specific to any build system. Signed-off-by: John Ogness --- schulung_tools/linking/hello/objdump.txt | 11 ----------- schulung_tools/linking/hello/shared_library.txt | 20 -------------------- schulung_tools/linking/objdump.txt | 11 +++++++++++ schulung_tools/linking/shared_library.txt | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 schulung_tools/linking/hello/objdump.txt delete mode 100644 schulung_tools/linking/hello/shared_library.txt create mode 100644 schulung_tools/linking/objdump.txt create mode 100644 schulung_tools/linking/shared_library.txt diff --git a/schulung_tools/linking/hello/objdump.txt b/schulung_tools/linking/hello/objdump.txt deleted file mode 100644 index 9c77720..0000000 --- a/schulung_tools/linking/hello/objdump.txt +++ /dev/null @@ -1,11 +0,0 @@ -# identify dependencies -objdump -x some_elf_file | grep NEEDED - -# identify SONAME used by dynamic loader -objdump -x some_lib | grep SONAME - -# identify runtime library search paths -objdump -x some_elf_file | grep PATH - -# identify path of dynamic loader (search for "interp") -objdump -s some_elf_file | less diff --git a/schulung_tools/linking/hello/shared_library.txt b/schulung_tools/linking/hello/shared_library.txt deleted file mode 100644 index 1dd0f9f..0000000 --- a/schulung_tools/linking/hello/shared_library.txt +++ /dev/null @@ -1,20 +0,0 @@ -# build shared library -gcc -fPIC -shared -Wl,-soname,libhello.so.1 -olibhello.so.1.0.3 libhello.c - -# install shared library -sudo mkdir -p /opt/myfirma/lib -sudo cp libhello.so.1.0.3 /opt/myfirma/lib - -# add custom path to dynamic loader search path -echo "/opt/myfirma/lib" | sudo tee /etc/ld.so.conf.d/myfirma.conf - -# refresh dynamic loader cache -sudo ldconfig - -# verify custom library is in cache -/sbin/ldconfig -p | grep libhello.so.1 - -# compile program using custom library -ln -s /opt/myfirma/lib/libhello.so.1.0.3 libhello.so -gcc -L. -ohello hello.c -lhello -rm libhello.so diff --git a/schulung_tools/linking/objdump.txt b/schulung_tools/linking/objdump.txt new file mode 100644 index 0000000..9c77720 --- /dev/null +++ b/schulung_tools/linking/objdump.txt @@ -0,0 +1,11 @@ +# identify dependencies +objdump -x some_elf_file | grep NEEDED + +# identify SONAME used by dynamic loader +objdump -x some_lib | grep SONAME + +# identify runtime library search paths +objdump -x some_elf_file | grep PATH + +# identify path of dynamic loader (search for "interp") +objdump -s some_elf_file | less diff --git a/schulung_tools/linking/shared_library.txt b/schulung_tools/linking/shared_library.txt new file mode 100644 index 0000000..1dd0f9f --- /dev/null +++ b/schulung_tools/linking/shared_library.txt @@ -0,0 +1,20 @@ +# build shared library +gcc -fPIC -shared -Wl,-soname,libhello.so.1 -olibhello.so.1.0.3 libhello.c + +# install shared library +sudo mkdir -p /opt/myfirma/lib +sudo cp libhello.so.1.0.3 /opt/myfirma/lib + +# add custom path to dynamic loader search path +echo "/opt/myfirma/lib" | sudo tee /etc/ld.so.conf.d/myfirma.conf + +# refresh dynamic loader cache +sudo ldconfig + +# verify custom library is in cache +/sbin/ldconfig -p | grep libhello.so.1 + +# compile program using custom library +ln -s /opt/myfirma/lib/libhello.so.1.0.3 libhello.so +gcc -L. -ohello hello.c -lhello +rm libhello.so -- cgit v1.2.3