it.Commit 3715f1d makes the error message of bound check on x86_64
different from other platforms,which breaks the test process.But that
commit exactly works well.
commit ec5d94291 made is to that the nocode_wanted state from
inside a statement expression is retained after it. That is wrong
if the statement expression can't be entered to start with. In the
latter case the state from before the stmt-expr is the one we need.
The main problem is that an application called dlclose and then
had a bound checking problem. The list of dll's in tccrun was
not updated an caused a crash.
Also fixed some minor other things.
tccdbg.c:
- Allow filenames like ../file.c
- Rewrite DWARF_ABBREV_MEMBER_BF/DWARF_ABBREV_MEMBER a bit
tccelf.c:
- Add call to __bt_exit. This solves problem when dlclose is called
tccrun.c:
- Rewrite rt_printline_dwarf a litlle to use opcode_length correctly
- Do not stop at DW_LNE_end_sequence
- Fix DW_LNE_set_address again. Works now in *bsd.
lib/bt-exe.c lib/bt-dll.c:
- Add __bt_exit/__bound_exit_dll
lib/bcheck.c:
- Add __bound_exit_dll
tccgen.c:
- When __FUNCTION__ is used and no code is generated use symbol len = 0.
tccelf.c:
- If library is present in verneed it should be in DT_NEEDED.
- @plt symbols should have size 0
- set _GLOBAL_OFFSET_TABLE_ st_size correct
- Remove version symbol if new value present
reported by elflint:
__FUNCTION__ problem:
section [19] '.symtab': symbol 2134 (L.195) does not fit completely in referenced section [14] '.data.ro'
DT_NEEDED problem:
section [26] '.gnu.version_r': entry 2 references unknown dependency
@plt symbols should have size 0:
section [22] '.symtab': symbol 36557 (r_core_config_init@plt) does not fit completely in referenced section [14] '.plt'
_GLOBAL_OFFSET_TABLE_ size:
section [44] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol size 4 does not match .got section size 736
Remove version symbol:
section [25] '.gnu.version': symbol 86: version index 3 is for requested version
This happened for example with bounds checking symbol malloc
Using the environment CC is a common used feature to
select a compiler to build any software,
so it should be supported when building tcc.
The old way using the parameter --cc still works.
(resend)
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
tccdbg.c
- Fix typo in dwarf_file. This resulted in not finding correct include
files.
tccrun.c:
- Change FILE_TABLE_SIZE to 512. Some files use very large includes.
- When a dll containted more then 1 file the pc was not calculated
correctly.
Some small updates in tccdbg.c found by checking readelf output from
gcc/clang.
- Change encoding type bool type
- Fix enum signed/unsigned
- Do not hash anon symbol
- Use correct filename/line_number for global variables
- Fix compiler warning in tcc_get_dwarf_info
- Use unsigned long long for array indexes
- Display correct first line of function in gdb
Better avoid global variables, at least in new code.
tccdbg.c hopefully should be logically identical to the
former parts in tccgen/elf.c (s1 tccstate added in some
places)
tccelf.c: dwarf linkage seems special per dwarf rather
than special per target.
/* Use "-g" as alias for "-g1". Use "-g0" to disable debug */
So not using -g is now the alias for -g0 ?!?
This reverts commit 8759b2581d.
This reverts commit 3ce7bc6efc.
This reverts commit 5fb582ab7f.
This reverts commit aea68dbb40.
This reverts commit fa9c31c3db.
This reverts commit b3bebdb20a.
This reverts commit ecf8e5a00e.
This reverts commit fe6b5c08dc.
This reverts commit e2e5377e7b.
This reverts commit 1cd7998905.
readelf complained about DW_AT_stmt_list and DW_AT_location.
For dwarf >= 4 we should use DW_FORM_sec_offset instead of DW_FORM_data4
and DW_FORM_exprloc instead of DW_FORM_block1.
This is fixed in tccgen.c
I also updated tccrun.c to use dwarf_read_1 instead of DW_GETC.
This if for clang (pre)release 15.0.0.
tccrun.c:
- update directory/filename read. clang has extra md5 section
- start with filename 0 instead of 1. clang starts at 0
- change dwarf_read_32/dwarf_read_64 into macros
x86_64-link.c:
- Add support for R_X86_64_DTPOFF64/R_X86_64_TPOFF64. Needed by clang
tests/tcctest.c:
- add prototypes for puts/alloca. clang fails with error
- disable other_constraints_test for clang. clang prints 1 instead of 0
tccgen.c:
- add anon support. So tcc_state in tcc works now.
- add function pointer support
- remove DW_FORM_implicit_const from DW_TAG_pointer_type
tccrun.c:
- set initial file name
- correctly use pc in DW_LNE_set_address (see lib/bt-exe.c)
- add DW_LNE_define_file support (even if it is deprecated)
tccelf.c
- do not include debug/test_coverage information for stub functions
lib/bt-exe.c
- use num_callers=-1 to mark dll
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
The code needs to be fixed: use the functions or remove them.
arm-asm.c:
asm_parse_vfp_regvar()
arm64-link:
gotplt_entry_type()
create_plt_entry()
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
Warnings reported in in x86_64-gen.c and arm-gen.c:
warning: ‘align’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
Target buffer must be larger as the format string + the replacement for %s
to avoid a warning [-Wformat-truncation=]
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
Using the environment CC is a common used feature to
select a compiler to build any software,
so it should be supported when building tcc.
The old way using the parameter --cc still works.
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
Some headers and source code change macros and
implementation, when __OPTIMIZE_SIZE__ is defined.
This does not change our generated code.
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
With this code, we can compile more projects,
who expect gcc or clang as compiler. (-std=gnu11 used in Makefiles)
As a further extension, it would be easy to disable gcc extensions
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>