Link without strip

General FreeBASIC programming questions.
vilhelmgray
Posts: 2
Joined: Apr 16, 2019 9:43

Link without strip

Postby vilhelmgray » Apr 16, 2019 9:54

It looks like fbc calls ld with the "--strip-all" option by default. Is there a way to link without stripping all symbols?

Code: Select all

$ fbc foobar.bas
$ file foobar
foobar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, stripped


I am aware that passing the "-g" option will prevent stripping, but this also adds debug_info to the executable which I do not want.

Code: Select all

$ fbc foobar.bas
$ file foobar
foobar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
Last edited by vilhelmgray on Apr 18, 2019 6:24, edited 1 time in total.
SARG
Posts: 884
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Link without strip

Postby SARG » Apr 16, 2019 13:17

Maybe by adding : --strip-debug (for the linker) with the g option
--strip-debug -> Omit debugger symbol information (but not all symbols) from the output file.
vilhelmgray
Posts: 2
Joined: Apr 16, 2019 9:43

Re: Link without strip

Postby vilhelmgray » Apr 18, 2019 6:23

SARG wrote:Maybe by adding : --strip-debug (for the linker) with the g option
--strip-debug -> Omit debugger symbol information (but not all symbols) from the output file.


Thank you, it looks like this works. I was able to accomplish what I wanted with the following line:

Code: Select all

$ fbc -g -Wl --strip-debug foobar.bas
$ file foobar
foobar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped


Interestingly, it looks like the "-g" option is not necessary (I suppose the "-Wl" option alone is enough to redefine the linker flags and eliminate the default "--strip-all"):

Code: Select all

$ fbc -Wl --strip-debug foobar.bas
$ file foobar
foobar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests