The .text section for the following program (program.c) changes after toggling the -g flag.
$ cat program.c
int a, b;
void c() {
for (;;)
;
}
int main() {}
$
$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 3890ce708d4f94d0326172650ce22262f6b56661)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang-trunk -c -m32 -O0 program.c ; objdump --disassemble --section=.text program.o > no_g.txt
$ clang-trunk -c -m32 -O0 -g program.c ; objdump --disassemble --section=.text program.o > g.txt
$ diff no_g.txt g.txt
10,11c10,11
< 3: e9 00 00 00 00 jmp 8 <b+0x4>
< 8: e9 fb ff ff ff jmp 8 <b+0x4>
---
> 3: e9 00 00 00 00 jmp 8 <c+0x8>
> 8: e9 fb ff ff ff jmp 8 <c+0x8>
Extended Description
The .text section for the following program (program.c) changes after toggling the -g flag.