[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] linux/unix shared libraries?
From: |
grischka |
Subject: |
Re: [Tinycc-devel] linux/unix shared libraries? |
Date: |
Fri, 25 Apr 2008 19:18:10 +0200 |
From: "grischka":
> ...
> The problem with the layout from TCC seem to be that the dynamic
> linker (/lib/ld-linux.so.2) thinks RELSZ is the size of rel.text,
> and then crashes when it goes over the end of it.
The above from my last email was somewhere near but still wrong.
TCC is okay to add on the sizes because it has all that sections
in order.
Instead it looks like if it generates bogus relocations for sections
with zero size. From objdump -x libmylib.so:
Idx Name Size VMA LMA File off Algn
11 .debug_line 00000000 00000000 00000000 000004a0 2**0
12 .rel.debug_line 00000038 00000360 00000360 00000360 2**2
This patch fixes it for me:
diff --git a/tccelf.c b/tccelf.c
index 730643d..e17f2df 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1372,7 +1372,9 @@ int tcc_output_file(TCCState *s1, const char *filename)
if (file_type == TCC_OUTPUT_DLL &&
s->sh_type == SHT_REL &&
!(s->sh_flags & SHF_ALLOC)) {
- prepare_dynamic_rel(s1, s);
+ /* //gr: avoid bogus relocs for empty (debug) sections */
+ if (s1->sections[s->sh_info]->sh_flags & SHF_ALLOC)
+ prepare_dynamic_rel(s1, s);
} else if (do_debug ||
file_type == TCC_OUTPUT_OBJ ||
(s->sh_flags & SHF_ALLOC) ||
--- grischka