102.3 Manage shared libraries

Description

102.3 Manage shared libraries
Rolando Martinez
Mind Map by Rolando Martinez, updated more than 1 year ago
Rolando Martinez
Created by Rolando Martinez over 3 years ago
5
0

Resource summary

102.3 Manage shared libraries
  1. shared libraries, also known as shared objects:
    1. pieces of compiled
      1. reusable code like functions or classes
        1. are recurrently used by various programs
          1. explain what shared libraries
            1. How to identify them and where they are found
              1. how to configure their storage locations
                1. how to search for the shared libraries on which a particular program depends.
              2. Concept of Shared Libraries
                1. software libraries are collections of code that are intended to be used by many different programs;
                  1. To build an executable file from a program’s source code
                    1. compiler gnerate Codigo Objeto
                      1. Linker Generate Codigo Executable
                        1. Dinamico
                          1. not copy any library code into the program file.
                            1. Library Used By Progrms Multiples
                              1. Resources Economic
                              2. Static
                                1. Library Linked in Program
                                  1. Heavy
                                    1. Dependencia Resolved
                              3. Shared Object File Naming Conventions
                                1. The name of a shared library, also known as soname, follows a pattern which is made up of three elements:
                                  1. so (which stands for “shared object”)
                                    1. Library name (normally prefixed by lib)
                                      1. Version number of the library
                                        1. Here an example: libpthread.so.0
                                          1. By contrast, static library names end in .a, e.g. libpthread.a.
                                        2. Exampes Of Shared Libraries
                                          1. glibc (GNU C library) i
                                            1. On a Debian GNU/Linux 9.9 system, its file is named libc.so.6
                                              1. Such rather general file names are normally symbolic links that point to the actual file containing a library, whose name contains the exact version number
                                                1. ls -l /lib/x86_64-linux-gnu/libc.so.6 lrwxrwxrwx 1 root root 12 feb 6 22:17 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.24.so
                                              2. libreadline
                                                1. which allows users to edit command lines as they are typed in and includes support for both Emacs and vi editing mode
                                                2. libcrypt
                                                  1. which contains functions related to encryption, hashing, and encodin
                                                  2. libcurl
                                                    1. which is a multiprotocol file transfer library
                                                  3. /lib /lib32 /lib64 /usr/lib /usr/local/lib
                                                    1. Locaciones
                                                  4. Configuration of Shared Library Paths
                                                    1. The references contained in dynamically linked programs are resolved by the dynamic link
                                                      1. ld.so
                                                        1. ld-linux.so
                                                          1. The dynamic linker searches for libraries in a number of directories
                                                            1. Library Path
                                                              1. The library path is configured in the /etc directory
                                                                1. /etc/ld.so.conf
                                                                  1. $ cat /etc/ld.so.conf include /etc/ld.so.conf.d/*.conf
                                                                  2. /etc/ld.so.conf.d/*.conf
                                                                    1. $ ls /etc/ld.so.conf.d/ libc.conf x86_64-linux-gnu.conf
                                                                      1. $ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf # Multiarch support /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
                                                                  3. ldconfig command
                                                                    1. set of symbolic links that help to locate the individual libraries
                                                                      1. finally of updating the cache file /etc/ld.so.cache
                                                                        1. options ldconfig
                                                                          1. ldconfig -v
                                                                            1. /usr/local/lib: /lib/x86_64-linux-gnu: libfuse.so.2 -> libfuse.so.2.9.7 libidn.so.11 -> libidn.so.11.6.16
                                                                              1. So we can see, for example, how libfuse.so.2 is linked to the actual shared object file libfuse.so.2.9.7.
                                                                            2. sudo ldconfig -p
                                                                              1. 1094 libs found in the cache `/etc/ld.so.cache' libzvbi.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libzvbi.so.0
                                                                                1. sudo ldconfig -p |grep libfuse libfuse.so.2 (libc6,x86-64) => /lib/x86_64-linux-gnu/libfuse.so.2
                                                                                  1. $ ls -l /lib/x86_64-linux-gnu/libfuse.so.2 lrwxrwxrwx 1 root root 16 Aug 21 2018 /lib/x86_64-linux-gnu/libfuse.so.2 -> libfuse.so.2.9.7
                                                                    2. LD_LIBRARY_PATH
                                                                      1. variable can be used to add new paths for shared libraries temporarily.
                                                                        1. LD_LIBRARY_PATH=/usr/local/mylib
                                                                          1. echo $LD_LIBRARY_PATH
                                                                            1. export LD_LIBRARY_PATH=/usr/local/mylib
                                                                              1. unset LD_LIBRARY_PATH
                                                                        2. permanente: /etc/bash.bashrc or ~/.bashrc.
                                                                      2. Searching for the Dependencies of a Particular Executable
                                                                        1. ldd /usr/bin/git
                                                                          1. To look up the shared libraries required by a specific program
                                                                          2. $ ldd /lib/x86_64-linux-gnu/libc.so.6 /lib64/ld-linux-x86-64.so.2 (0x00007fbfed578000) linux-vdso.so.1 (0x00007fffb7bf5000)
                                                                            1. ldd to search for the dependencies of a shared object:
                                                                            2. ldd -u /usr/bin/git
                                                                              1. ldd prints the unused direct dependencies
                                                                              2. readelf
                                                                                1. Display information about ELF files (ELF stands for executable and linkable format)
                                                                                  1. -h:This will display the top-level headers -
                                                                                    1. -S: To display information about the different sections of the process’ address space.
                                                                                      1. -s: To display symbols table.
                                                                                        1. -n: To display core notes
                                                                                          1. -r: To display relocation section.
                                                                                            1. -d:To display the dynamic section.
                                                                                              1. -v:To get the version of the readelf command.
                                                                                2. objdump
                                                                                  1. Print information from object files.
                                                                                    1. Display the contents of the overall file header using -f option. ... Display the contents of the section headers using -h option. ... Display the contents of all headers using -x option. ...Display assembler contents of executable sections using -d option.Display assembler contents of all sections using -D option.
                                                                                      1. -a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,
                                                                                        1. Use objdump con el -p (o --private-headers) y grep para imprimir las dependencias de glibc: objdump -p /lib/x86_64-linux-gnu/libc.so.6 | grep NEEDED
                                                                                          1. Use objdump con el -p (o --private-headers) y grep para imprimir el soname de glibc: objdump -p /lib/x86_64-linux-gnu/libc.so.6 | grep SONAME
                                                                                            1. Use objdump con el -p (o --private-headers) y grep para imprimir las dependencias de Bash: objdump -p /bin/bash | grep NEEDED
                                                                                          2. objdump -p /lib/x86_64-linux-gnu/libc.so.6
                                                                                            1. grep NEEDED grep soname
                                                                                            2. objdump -p /bin/bash | grep NEEDED
                                                                                          3. Comandos
                                                                                            1. objdump: Imprime información de archivos de objetos.
                                                                                              1. ls:Lista el contenido de un directorio.
                                                                                                1. cat: Concatena archivos e imprime en la salida estándar.
                                                                                                  1. sudo: Hace que el superusuario ejecute el comando con privilegios administrativos.
                                                                                                    1. ldconfig: Configura enlaces de tiempo de ejecución del vinculador dinámico.
                                                                                                      1. echo: Muestra el valor de la variable de entorno.
                                                                                                        1. export Valor de exportación de la variable de entorno a shells secundarios.
                                                                                                          1. unset Elimina variables de entorno.
                                                                                                            1. ldd Imprime dependencias de objetos compartidos de un programa.
                                                                                                              1. readelf Muestra información sobre archivos ELF (ELF significa executable and linkable format).
                                                                                                              2. Ha desarrollado un software y desea agregar un nuevo directorio de biblioteca compartida a su sistema (/opt/lib/mylib). Escriba su ruta absoluta en un archivo llamado mylib.conf.
                                                                                                                1. ¿En qué directorio debe almacenar este archivo? /etc/ld.so.conf.d
                                                                                                                  1. ¿Qué comando debe ejecutar para que los cambios sean totalmente efectivos? ldconfig
                                                                                                                    1. ¿Qué comando usaría para listar las bibliotecas compartidas requeridas por kill? ldd /bin/kill
                                                                                                                    Show full summary Hide full summary

                                                                                                                    Similar

                                                                                                                    B1 Biology
                                                                                                                    Emily Needham
                                                                                                                    US Graduate Schools by Course
                                                                                                                    SAT Prep Group
                                                                                                                    MCAT Review: Human Skeletal System
                                                                                                                    toronto416
                                                                                                                    Chemistry C1
                                                                                                                    Chloe Winn
                                                                                                                    Math's Core 1
                                                                                                                    mitchcharlie
                                                                                                                    ENG LIT TECHNIQUES
                                                                                                                    Heloise Tudor
                                                                                                                    Geography Tourism
                                                                                                                    lauramarypowell
                                                                                                                    Chemistry revision
                                                                                                                    Jordyn Niu
                                                                                                                    Frankenstein - Mary Shelley
                                                                                                                    Johnny Hammer
                                                                                                                    PuKW - FOLO Wippersberg (mögliche Prüfungsfragen/Prüfungsvorbereitung)
                                                                                                                    Kamelia Kostadinova