On 2020-01-19 12:06, grischka wrote:
Herman ten Brugge wrote:
Btw, there seems to be a bug in the sym-version code that crashes
tcc when it tries to link with a .so, for example:
echo "void f() {}" | tcc - -shared -o a.so
echo "main() {}" | tcc - a.so
<segmentation fault>
I cannot reproduce this. I checkout a fresh copy and see no problem.
I use Fedora 31 with all updates.
see for example
https://gitlab.com/giomasce/tinycc/-/jobs/408014593
+./a.exe: error while loading shared libraries: ./a1.so: unsupported
version
25960 of Verneed record
I could reproduce this. The attached patch fixes this.
Regards,
Herman
diff --git a/tccelf.c b/tccelf.c
index fe00a30..332f283 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -2045,9 +2045,11 @@ static void fill_dynamic(TCCState *s1, struct dyn_inf
*dyninf)
put_dt(dynamic, DT_RELENT, sizeof(ElfW_Rel));
#endif
#endif
- if (versym_section) {
+ if (verneed_section && verneed_section->data) {
put_dt(dynamic, DT_VERNEED, verneed_section->sh_addr);
put_dt(dynamic, DT_VERNEEDNUM, dt_verneednum);
+ }
+ if (versym_section && versym_section->data) {
put_dt(dynamic, DT_VERSYM, versym_section->sh_addr);
}
s = find_section_create (s1, ".preinit_array", 0);
@@ -2522,11 +2524,13 @@ ssize_t full_read(int fd, void *buf, size_t count) {
static void *load_data(int fd, unsigned long file_offset, unsigned long size)
{
- void *data;
+ void *data = NULL;
- data = tcc_malloc(size);
- lseek(fd, file_offset, SEEK_SET);
- full_read(fd, data, size);
+ if (size) {
+ data = tcc_malloc(size);
+ lseek(fd, file_offset, SEEK_SET);
+ full_read(fd, data, size);
+ }
return data;
}
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel