- 8 Примеров команд LDD в Linux
- Общие библиотеки
- Синтаксис и параметры
- 1) Отобразить зависимости команды
- 2) Отобразить зависимости команды с деталями
- 3) Отображение неиспользуемых прямых зависимостей команды
- 4) Работа только с динамическими исполняемыми файлами
- 5) ldd со стандартной исполняемой командой
- 6) Установите, что данный исполняемый демон поддерживает TCP Wrapper
- 7) ldd с отсутствующей зависимостью
- Thread: how to read .so file in ubuntu
- how to read .so file in ubuntu
- Re: how to read .so file in ubuntu
- Re: how to read .so file in ubuntu
- Re: how to read .so file in ubuntu
- Linux vdso so 1 ubuntu
- Примеры использования
- Вывод списка разделяемых библиотек, используемых приложением
- Вывод списка разделяемых библиотек, используемых разделяемой библиотекой
- Вывод подробного списка разделяемых библиотек, используемых приложением
- 8 LDD Command Examples in Linux
- Shared libraries
- LDD Command Syntax & Options
- 1) Display dependencies of the command
- 2) Display dependencies of the command with details
- 3) Display unused direct dependencies of the command
- 4) Display ldd works only on dynamic executables
- 5) ldd with standard command line executable
- 6) Know a given executable daemon supports TCP Wrapper
- 7) ldd with missing dependency
- Common shared library related errors
- 1) Missing library error
- 2) Dynamic linker error, can’t map cache files
- ldconfig Command
- For Examples:
- Conclusion
8 Примеров команд LDD в Linux
ldd – это утилита командной строки Linux, которая используется в том случае, если пользователь хочет знать зависимости от общей библиотеки исполняемого файла или даже библиотеки разделяемой библиотеки.
Библиотека представляет собой набор ресурсов, таких как подпрограммы / функции, классы, значения или спецификации типов.
Существует два типа библиотек:
Статические библиотеки: статические библиотеки для полных программ, которые не зависят от запуска внешних библиотек. Особенностью статически связанных программ является то, что они работают без установки каких-либо предварительных условий. Статическая библиотека заканчивается расширением * .a, и эти библиотеки включены (отдельная копия) в программы, для которых требуются ее функции.
Динамические библиотеки: динамические библиотеки для небольших программ по размеру. Эти библиотеки заканчиваются расширением .so. Еще одна особенность использования динамической компоновки при запуске многих программ. Она может использовать одну копию библиотеки, а не занимать память многими копиями одного и того же кода , Таким образом, последние программы используют динамическое связывание. В этой статье мы рассмотрим команды ldd, которые используются для управления разделяемыми библиотеками.
Общие библиотеки
Когда мы создаем программу, нам нужно много фрагментов кода, которые кто-то написал для выполнения обычных или специализированных функций в наших целях.
Эти фрагменты кода хранятся в разделяемых библиотеках.
Чтобы использовать их, мы связываем их с нашим кодом либо при создании программы, либо при запуске программы.
Синтаксис и параметры
Команда ldd выводит зависимости общих объектов. Синтаксис команды:
Мы можем использовать команды ldd с опциями
- -v: вывести всю информацию.
- -d: перемещение данных процесса.
- -r: данные процесса и перемещение функций.
- -u: вывод неиспользуемых прямых зависимостей.
1) Отобразить зависимости команды
Мы будем отображать зависимости команды cp.
2) Отобразить зависимости команды с деталями
Мы будем отображать зависимости команды cp с более подробной информацией, используя опцию -v.
3) Отображение неиспользуемых прямых зависимостей команды
Мы можем отобразить неиспользуемые прямые зависимости команды cp с использованием опции -u.
4) Работа только с динамическими исполняемыми файлами
Мы выведем ldd только для динамических исполняемых файлов с использованием опции -r.
На выводе было отображено сообщение о том, что предоставленный файл не является динамическим исполняемым файлом.
5) ldd со стандартной исполняемой командой
Когда мы пытаемся выполнить ldd со стандартной командой, например ls, нам нужен полный путь к динамическому исполняемому файлу.
Мы видим, что ldd утверждает, что он не может найти ls.
Но с абсолютным путем ldd работал нормально.
6) Установите, что данный исполняемый демон поддерживает TCP Wrapper
Чтобы определить, поддерживает ли данный исполняемый демона TCP Wrapper или нет, выполните следующую команду.
Результат показывает, что демон OpenSSH (sshd) поддерживает TCP Wrapper.
7) ldd с отсутствующей зависимостью
Мы можем использовать команду ldd, когда исполняемый файл выходит из строя из-за отсутствующей зависимости.
Как только мы обнаружили недостающую зависимость, мы можем установить ее или обновить кеш командой ldconfig.
Мы будем выполнять перемещение и сообщать о любых недостающих объектах (только ELF), набрав команду ниже.
Мы будем выполнять перемещение для объектов и функций данных и сообщать о любых недостающих объектах или функциях (только для ELF), набрав команду ниже.
Источник
Thread: how to read .so file in ubuntu
Thread Tools
Display
how to read .so file in ubuntu
hi every one,
I am again face a problem. According your suggestion i can convert a .c file to .so file and tell me in which way i can open that .so file i.e. i want to see what will be the code after creating my .so file. I will be highly obliged if any one can give me more information .so file related.
Re: how to read .so file in ubuntu
.so file is a shared library. It is not directly usable. It is fed into the linker when linking your programs.
The first 2 are added by the linker, the last one is the one that comes from the object code.
To build an application against this library:
In this place, __libc_start_main@@GLIBC_2.2.5 is a symbol defined by the C library, foo is a symbol defined by our shared library. It is completed by loading /usr/local/lib/libfoo.so.1 at runtime.
Last edited by miklcct; September 3rd, 2009 at 10:16 AM .
Re: how to read .so file in ubuntu
.so file is a shared library. It is not directly usable. It is fed into the linker when linking your programs.
The first 2 are added by the linker, the last one is the one that comes from the object code.
To build an application against this library:
Thanks for your help. Since i am new in ubuntu so there arise few questions. These are as follows:
1) In your comments you wrote foo.h. Now my question is whether it is (filename.h) necessary or not.
2) If you know any URL link on .so file related please post here for developing my knowledge on Ubuntu and .so file related.
Re: how to read .so file in ubuntu
The source codes contain .c and .h files. To convert a .c file to a .so file, the compiler actually performs 4 steps:
- Run cpp to generate .i file from .c file (Preprocessing)
- Run cc1 to generate .s file from .i file (Compiling)
- Run as to generate .o file from .s file (Assembling)
- Run ld to generate .so file from .o file(s) (Linking) (A shared object can contain more than 1 .o files)
Источник
Linux vdso so 1 ubuntu
Команда ldd предназначена для вызова одноименной утилиты, осуществляющей вывод списка разделяемых библиотек, используемых исполняемыми файлами или разделяемыми библиотеками. Разделяемые библиотеки обычно содержат реализации функций, которые необходимы для корректной работы приложений или других разделяемых библиотек. Разделяемые библиотеки (*.so) являются полным аналогом динамических библиотек (*.dll) из Windows.
Базовый синтаксис команды выглядит следующим образом:
$ ldd [параметры] [путь-к-разделяемой-библиотеке]
Утилита поддерживает параметр -v, позволяющий выводить дополнительную информацию о версиях используемых разделяемых библиотек, параметр -u, позволяющий выводить список связанных, но не используемых разделяемых библиотек, а также параметры -d и -r, позволяющие осуществлять релокации объектов данных и функций.
Рассматриваемая утилита может понадобиться в процессе разработки программного обеспечения, а также создания пакетов для его распространения.
Стоит упомянуть и о том, что система кэширует информацию о доступных разделяемых библиотеках и хранит ее в файле с именем /etc/ld.so.cache (файл не предназначен для редактирования с помощью обычного текстового редактора). Существует и файл конфигурации /etc/ld.so.conf, в котором содержится список путей к директориям, в которых размещены разделяемые библиотеки. Разделяемая библиотека с именем ld-linux-*.so выполняет функции динамического линковщика, то есть, осуществляет поиск необходимых для работы приложения разделяемых библиотек в кэше и загружает их. Помимо этого существует системная утилита ldconfig, предназначенная для обновления кэша разделяемых библиотек.
Также существует вспомогательная виртуальная разделяемая библиотека linux-vdso.so (или linux-gate.so на некоторых архитектурах), которая отображается ядром Linux в адресное пространство всех пользовательских процессов и используется библиотекой языка C libc для повышения производительности при работе с некоторыми системными вызовами. На нее не стоит обращать особого внимания.
Примеры использования
Вывод списка разделяемых библиотек, используемых приложением
Для вывода списка разделяемых библиотек, используемых приложением, следует передать утилите путь к интересующему приложению.
$ ldd /bin/nano
linux-vdso.so.1 (0x00007ffc5e1d3000)
libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007fed3b9e8000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fed3b9b8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed3b7c7000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fed3b7c1000)
/lib64/ld-linux-x86-64.so.2 (0x00007fed3ba8f000)
Как видно, для работы приложения nano требуется ряд разделяемых библиотек, причем первой библиотекой является вспомогательная библиотека ядра Linux, а последней — библиотека динамического линковщика.
Вывод списка разделяемых библиотек, используемых разделяемой библиотекой
Для вывода списка разделяемых библиотек, используемых другой разделяемой библиотекой, следует передать утилите путь к интересующей разделяемой библиотеке.
$ ldd /lib/x86_64-linux-gnu/libc-2.30.so
/lib64/ld-linux-x86-64.so.2 (0x00007f8d28fad000)
linux-vdso.so.1 (0x00007ffe62b78000)
Библиотека libc использует лишь вспомогательные разделяемые библиотеки.
$ ldd /lib/x86_64-linux-gnu/libbz2.so.1
linux-vdso.so.1 (0x00007ffc757cb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3bd62f4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3bd6516000)
Библиотека libbz2 использует библиотеку libc.
Вывод подробного списка разделяемых библиотек, используемых приложением
Для вывода подробного списка разделяемых библиотек, используемых приложением, следует использовать параметр -v.
$ ldd -v /bin/nano
linux-vdso.so.1 (0x00007fff4cfcf000)
libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007f43c1744000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f43c1714000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f43c1523000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f43c151d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f43c17eb000)
Version information:
/bin/nano:
libtinfo.so.6 (NCURSES6_TINFO_5.4.20040208) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.0.19991023) => /lib/x86_64-linux-gnu/libtinfo.so.6
libc.so.6 (GLIBC_2.27) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.6) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
libncursesw.so.6 (NCURSESW6_5.7.20081102) => /lib/x86_64-linux-gnu/libncursesw.so.6
libncursesw.so.6 (NCURSESW6_5.1.20000708) => /lib/x86_64-linux-gnu/libncursesw.so.6
/lib/x86_64-linux-gnu/libncursesw.so.6:
libdl.so.2 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libdl.so.2
libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.9.20150530) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.5.20051010) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.1.20000708) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.2.20001021) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.6.20061217) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.7.20081102) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.8.20110226) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.4.20040208) => /lib/x86_64-linux-gnu/libtinfo.so.6
libtinfo.so.6 (NCURSES6_TINFO_5.0.19991023) => /lib/x86_64-linux-gnu/libtinfo.so.6
/lib/x86_64-linux-gnu/libtinfo.so.6:
libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.16) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libc.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
/lib/x86_64-linux-gnu/libdl.so.2:
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
Информация о версиях библиотек приведена в разделе Version information.
Источник
8 LDD Command Examples in Linux
Ldd is a Linux command line utility that is used in case a user wants to know the shared library dependencies of an executable or even that of a shared library. You might have noticed many files starting with lib* in /lib and /usr/lib directories of your Linux machine. These files are called libraries. Library is a collection of resources such as subroutines/functions, classes, values or type specifications.
A library makes it possible for a program to use common routines without the administrative overhead of maintaining their source code, or the processing overhead of compiling them each time the program is compiled.
There are two types of libraries:
Static libraries: static libraries for complete programs that do not depend on external libraries to run. The feature of statically linked programs is that they work without installing any prerequisites. The static library is end with *.a extension and these libraries are included (a separate copy) into the programs that require its functions.
Dynamic libraries: dynamic libraries for tiny programs in size, These libraries end with .so extension, Another feature of using dynamic linking when many programs are running, It can share one copy of a library rather than occupying memory with many copies of the same code. So the recent programs use dynamic linking. In this article, we will go through the commands ldd which is used to manage the shared libraries.
Shared libraries
When we make a program, we need many pieces of code that someone else has already written to perform routine or specialized functions for us. These pieces of code are stored in shared libraries. To use them, we link them with our code, either when we build the program or when we run the program.
LDD Command Syntax & Options
The ldd command prints shared object dependencies. The command’s syntax is:
We can use ldd command switches that can be inserted into the
[OPTION] spot in the above command:
- -v : Print all information.
- -d : process data relocation.
- -r : process data and function relocation.
- -u : print unused direct dependencies.
Please note down the following points before going through the command:
— The file, ld-linux.so is the dynamic linker or loader which checks for the desired link or library cache for the requested program and loads it.
— The cache file, /etc/ld.so.cache contains a list of libraries found in the directories specified in /etc/ld.so.conf. This helps to provide faster dynamic linking.
— The file /etc/ld.so.conf specifies the directories where to search for libraries
1) Display dependencies of the command
We will display the dependencies of cp command.
2) Display dependencies of the command with details
We will display the dependencies of cp command with more details using -v option.
3) Display unused direct dependencies of the command
We can display unused direct dependencies of cp command using -u option.
4) Display ldd works only on dynamic executables
We will display ldd works only on dynamic executables using -r option.
The output displayed a clear message state that the supplied file is not a dynamic executable.
5) ldd with standard command line executable
When we try ldd on a standard command line executable like ls , We need full path to the dynamic executable.
We see that ldd states that it cannot find ls .
But with the absolute path, ldd worked fine.
6) Know a given executable daemon supports TCP Wrapper
To determine whether a given executable daemon supports TCP Wrapper or not, run the following command.
The output indicates that the OpenSSH (sshd) daemon supports TCP Wrapper.
7) ldd with missing dependency
We can use the ldd command when an executable is failing because of a missing dependency. Once we found a missing dependency, we can install it or update the cache with the ldconfig command.
We will perform relocations and report any missing objects (ELF only) by typing below command.
We will perform relocations for both data objects and functions, and report any missing objects or functions (ELF only) by typing below command.
Common shared library related errors
1) Missing library error
You may encounter missing library error even though the mentioned libraries are available in the new installation path “/opt/newinstall/lib”. This is because the system is not aware of this directory to check for libraries. This can be fixed in any of the two ways.
a. Execute the following command,
b. You can see the following include line in /etc/ld.so.conf file:
So, create a file in /etc/ld.so.sonf.d folder, say newinstall.conf with the following content.
2) Dynamic linker error, can’t map cache files
This may be due to the corrupted cache file. This can be resolved by rebuilding the cache file using ldconfig.
ldconfig Command
ldconfig creates the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries found in the directories specified on the command line, in the file/etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib).
For Examples:
Execute the following command to set up the correct links for the shared binaries and rebuild the cache.
Execute the following command after the installation of a new shared library will properly update the shared library symbolic links in /lib.
The following command will print the current cache.
Conclusion
In this tutorial we learned how to use ldd command and how to use in linux command line. Hope you enjoyed reading this tutorial and please advise if you have any suggestions.
Источник