Skip to content

Commit 2f2708a

Browse files
committed
Add dwarf support
The new gcc12 release does not support stabs any more. This was a good reason to add support for dwarf. The stabs code still works and is used if configure option --dwarf is not used. Tested on x86_64, i386, arm, arm64, riscv64 with dwarf-5. Some debuggers may not support dwarf-5. Try using older dwarf versions i that case. The tccmacho.c code probably need some support for dwarf. arm-gen.c, arm64-gen.c, i386-gen.c, riscv64-gen.c, x86_64-gen. - fix get_sym_ref symbol size arm-link.c, arm64-link.c, i386-link.c, riscv64-link.c, x86_64-link.c - add R_DATA_32U libtcc.c: - parse -gdwarf option tcc.c: - add dwarf option tcc.h: - add dwarf option and sections tccelf.c: - init dwarf sections - avoid adding sh_addr for dwarf sections - remove dwarf relocs for output dll - add dwarf sections for tccrun tccgen.c: - add dwarf defines + global data - add dwarf_* functions - mix dwarf code with stabs code - a trick is used to emit function name in .debug_line section so only this section has to be parsed instead of .debug_info and .debug_abbrev. - fix init debug_modes tccrun.c: - add dwarf sections in rt_context - init them in tcc_run - add new dwarf code rt_printline_dwarf to find file/function dwarf.h: - New file tcc-doc.texi: - document dwarf configure: - add dwarf option lib/Makefile - change -gstabs into -gdwarf lib/bt-exe.c, tests/tests2/Makefile, tests/tests2/126_bound_global: - Add __bound_init call - Add new testcase to test it
1 parent d3e940c commit 2f2708a

26 files changed

+2754
-144
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config*.h
2424
config*.mak
2525
config.texi
2626
conftest*
27+
c2str
2728
tags
2829
TAGS
2930
tcc.1

arm-gen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ static void gen_bounds_epilog(void)
866866
*bounds_ptr = 0;
867867

868868
sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
869-
func_bound_offset, lbounds_section->data_offset);
869+
func_bound_offset, PTR_SIZE);
870870

871871
/* generate bound local allocation */
872872
if (offset_modified) {

arm-link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/* relocation type for 32 bit data relocation */
66
#define R_DATA_32 R_ARM_ABS32
7+
#define R_DATA_32U R_ARM_ABS32
78
#define R_DATA_PTR R_ARM_ABS32
89
#define R_JMP_SLOT R_ARM_JUMP_SLOT
910
#define R_GLOB_DAT R_ARM_GLOB_DAT

arm64-gen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ static void gen_bounds_epilog(void)
710710
*bounds_ptr = 0;
711711

712712
sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
713-
func_bound_offset, lbounds_section->data_offset);
713+
func_bound_offset, PTR_SIZE);
714714

715715
/* generate bound local allocation */
716716
if (offset_modified) {

arm64-link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define EM_TCC_TARGET EM_AARCH64
44

55
#define R_DATA_32 R_AARCH64_ABS32
6+
#define R_DATA_32U R_AARCH64_ABS32
67
#define R_DATA_PTR R_AARCH64_ABS64
78
#define R_JMP_SLOT R_AARCH64_JUMP_SLOT
89
#define R_GLOB_DAT R_AARCH64_GLOB_DAT

c67-link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/* relocation type for 32 bit data relocation */
66
#define R_DATA_32 R_C60_32
7+
#define R_DATA_32U R_C60_32
78
#define R_DATA_PTR R_C60_32
89
#define R_JMP_SLOT R_C60_JMP_SLOT
910
#define R_GLOB_DAT R_C60_GLOB_DAT

configure

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ ar_set=
5151
darwin=
5252
cpu=
5353
cpuver=
54+
dwarf=
5455

5556
# OS specific
5657
cpu_sys=`uname -m`
@@ -136,6 +137,8 @@ for opt do
136137
;;
137138
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2-`
138139
;;
140+
--dwarf=*) dwarf=`echo $opt | cut -d '=' -f 2-`
141+
;;
139142
--enable-cross) confvars="$confvars cross"
140143
;;
141144
--disable-static) confvars="$confvars static=no"
@@ -328,6 +331,7 @@ Advanced options (experts only):
328331
--config-backtrace=no disable stack backtraces (with -run or -bt)
329332
--config-bcheck=no disable bounds checker (-b)
330333
--config-predefs=no do not compile tccdefs.h, instead just include
334+
--dwarf=x Use dwarf debug info instead of stabs (x=2..5)
331335
EOF
332336
exit 1
333337
fi
@@ -493,6 +497,7 @@ print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
493497
print_mak CONFIG_LDDIR "$tcc_lddir"
494498
print_mak CONFIG_TRIPLET "$triplet"
495499
print_mak TCC_CPU_VERSION "$cpuver" num
500+
print_mak CONFIG_DWARF "$dwarf"
496501

497502
echo "ARCH=$cpu" >> config.mak
498503
echo "TARGETOS=$targetos" >> config.mak

0 commit comments

Comments
 (0)