Fixed
Created: Jul 10, 2018
Updated: Mar 22, 2019
Resolved Date: Aug 20, 2018
Found In Version: 8.0
Fix Version: 8.0.0.27
Severity: Severe
Applicable for: Wind River Linux 8
Component/s: Toolchain
Loading core with gdb does not decode shared libraries with ASLR
When loading a core file from an executable compiled/linked with "-fpie -pie" we are unable to get symbols for shared libs. Reproduced with simple program:
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <zlib.h>
int main() {
z_stream defstream;
int *x = NULL;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
deflateInit(&defstream, Z_BEST_COMPRESSION);
*x = 1;
return 0;
}
Compiling without –fpie –pie we get:
mips64el-wrs-linux-gdb asa/bin/lina_monitor
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-wrlinuxsdk-linux --target=mips64el-wrs-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from asa/bin/lina_monitor...Reading symbols from /f1/jlashua-lina-dev/Xpix/target/mips/temp/asa/bin/lina_monitor.dbg...done.
done.
(gdb) core core.lina_monitor.11.26311.1524592060
warning: exec file is newer than core file.
[New LWP 26311]
Core was generated by `./lina_monitor'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 main () at lina_monitor.c:26
26 *x = 1;
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x000000fff7a87850 0x000000fff7a96b40 Yes ./lib64/libz.so.1
0x000000fff7a58c60 0x000000fff7a6c660 Yes ./lib64/libpthread.so.0
0x000000fff7a3a4a0 0x000000fff7a3ec70 Yes ./lib64/librt.so.1
0x000000fff78b4fa0 0x000000fff79e46f0 Yes ./lib64/libc.so.6
0x000000fff7aae030 0x000000fff7acc7b0 Yes ./lib64/ld.so.1
Compiling with –fpie –pie we get:
mips64el-wrs-linux-gdb asa/bin/lina_monitor
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-wrlinuxsdk-linux --target=mips64el-wrs-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from asa/bin/lina_monitor...Reading symbols from /f1/jlashua-lina-dev/Xpix/target/mips/asa/bin/lina_monitor.dbg...done.
done.
(gdb) core core.lina_monitor.11.11654.1524588090
[New LWP 11654]
Core was generated by `./lina_monitor'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 main () at lina_monitor.c:26
26 *x = 1;
(gdb) info sharedlibrary
No shared libraries loaded at this time.
mips64 board;make export-sdk;
1.${CC} hello.c -fpie -pie -g -std=c99 -o hello -lz
2.${CC} hello.c -g -std=c99 -o hello-no -lz
copy the two executable binaries on target rootfs
Bootup and execute gdb
#gdb hello-no
(gdb)set stop-on-solib-events 1
(gdb)b main
(gdb)r
(gdb)info shared
(gdb)c
(gdb)info shared