cc does always create binary with debug_info, but I do not specified -g reddit / freebsd ---------------------------------------------------------------------- ImDoingInMyName · 2022-11-18 01:41 hello, folks. does clang creates always binary with debug\_info on freebsd 13? $> cat test.c \#include "stdio.h" int main(void) { printf("Hello, world!\\n"); return 0; } $>cc -o test test.c $>file test test: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, **with debug\_info**, not stripped $> strip -S test $> file test test: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, not stripped after strip, debug\_info has gone. why is that? ---------------------------------------------------------------------- kevans91 · 2022-11-18 06:10 I suspect what you're seeing is an artifact from one of the other objects that gets linked in. Note: root@ifrit:/tmp # cc --verbose -o test test.c FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm- project.git llvmorg-14.0.5-0-gc12386ae247c) Target: x86_64-unknown-freebsd14.0 Thread model: posix InstalledDir: /usr/bin "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd14.0 -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before- backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp -resource-dir /usr/lib/clang/14.0.5 -fdebug-compilation-dir=/tmp -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-3fefe8.o -x c test.c clang -cc1 version 14.0.5 based upon LLVM 14.0.5 default target x86_64-unknown-freebsd14.0 #include "..." search starts here: #include <...> search starts here: /usr/lib/clang/14.0.5/include /usr/include End of search list. "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o test /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/test-3fefe8.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o Specifically: /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o ... /usr/lib/crtend.o /usr/lib/crtn.o ... Each of these has their own .debug\_info. Finally, let's try another experiment: root@ifrit:/tmp # cc -c -o test.o test.c root@ifrit:/tmp # readelf -a test.o | grep -i debug # No output root@ifrit:/tmp # cc -g -c -o test.o test.c root@ifrit:/tmp # readelf -a test.o | grep -i debug [ 5] .debug_abbrev PROGBITS 0000000000000000 0000007a [ 6] .debug_info PROGBITS 0000000000000000 000000b0 [ 7] .rela.debug_info RELA 0000000000000000 00000360 [ 8] .debug_str PROGBITS 0000000000000000 000000fb [13] .debug_line PROGBITS 0000000000000000 00000218 [14] .rela.debug_line RELA 0000000000000000 00000450 Relocation section with addend (.rela.debug_info): 000000000006 00040000000a R_X86_64_32 0000000000000000 .debug_abbrev + 0 00000000000c 00050000000a R_X86_64_32 0000000000000000 .debug_str + 0 000000000012 00050000000a R_X86_64_32 0000000000000000 .debug_str + 67 000000000016 00060000000a R_X86_64_32 0000000000000000 .debug_line + 0 00000000001a 00050000000a R_X86_64_32 0000000000000000 .debug_str + 6e 000000000039 00050000000a R_X86_64_32 0000000000000000 .debug_str + 73 000000000044 00050000000a R_X86_64_32 0000000000000000 .debug_str + 78 Relocation section with addend (.rela.debug_line): Our initial theory seems to hold up- ---------------------------------------------------------------------- [deleted] · 2022-11-18 07:26 [deleted] ---------------------------------------------------------------------- ImDoingInMyName · 2022-11-18 07:27 Great! Thank you.