If it is a shared library
You, unfortunately, want; it is impossible to find out where the libraries were put into memory by the dynamic linker after .
Well, there is still the ability to extract information, not from binary, but from an object. But you need the base address of the object. And this information is still inside the coredump in the link_map structure.
So first you want to import the struct link_map into GDB. So let's compile the program with it using the debug symbol and add it to GDB.
link.c
#include <link.h> toto(){struct link_map * s = 0x400;}
get_baseaddr_from_coredump.sh
#!/bin/bash BINARY=$(which myapplication) IsBinPIE () { readelf -h $1|grep 'Type' |grep "EXEC">/dev/null || return 0 return 1 } Hex2Decimal () { export number="`echo "$1" | sed -e 's:^0[xX]::' | tr '[af]' '[AF]'`" export number=`echo "ibase=16; $number" | bc` } GetBinaryLength () { if [ $# != 1 ]; then echo "Error, no argument provided" fi IsBinPIE $1 || (echo "ET_EXEC file, need a base_address"; exit 0) export totalsize=0
it will bring you all the link_map content as part of the GDB team.
It may seem unnesseray, but with the base_addr of the shared object we are talking about, you can get additional information from the address by debugging the directly involved shared object in another GDB instance. Save the first gdb to have a character ideal.
NOTE: the script is rather incomplete, I suspect that you can add add-symbol to the second parameter of the file by printing the sum with this value:
readelf -S $SO_PATH|grep -E '\.text[ \t]'|awk '{print $5}'
where $ SO_PATH is the first argument of the add-symbol symbol file
Hope this helps
scripthelps Jun 06 2018-12-06T00: 00Z
source share