1 year ago
#362223
dg_linux
Why does gcc not produce DWARF5 bin even after passing ``-gdwarf-5`` flag?
I am trying to compile a basic c program to get the binary ELF on my Ubuntu x86-64 machine. I want the binary to comply with the DWARF5 format as I am working on writing a .debug_sup
section parser.
However I am not sure if this is because I have an older version of gcc or am I passing the wrong flags.
I am pretty sure I have the right binutils
version for parsing DWARF5 as the release notes here say.
The C- Program I am trying to build is as follows:
#include <stdio.h>
#include <stdlib.h>
/*
* === FUNCTION ======================================================================
* Name: main
* Description:
* =====================================================================================
*/
int
main ( int argc, char *argv[] )
{
int a = 10, b = 15;
int *ptra = &a, *ptrb = &b;
printf ("a = %d and b = %d\n", *ptra, *ptrb) ;
ptra = &b;
ptrb = &a;
printf ("a = %d and b = %d\n", *ptra, *ptrb) ;
int ** pptra = &ptra, **pptrb = &ptrb;
printf ("a = %d and b = %d\n", **pptra, **pptrb) ;
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
I try to compile it using gcc basic_declaration_of_pointer.c -gdwarf-5
however the objdump
of the binary still ends up showing older DWARF3 version.
The docs here is where I learned about the dwarf version flag.
My gcc version is as follows:
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
objdump version
āā⯠objdump --version
GNU objdump (GNU Binutils) 2.37
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
debugging
gcc
reverse-engineering
elf
dwarf
0 Answers
Your Answer