From 68c8c352fdfd0759b74b3ac9f699c079bb82ee75 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Thu, 12 Dec 2024 20:46:00 +0100 Subject: [PATCH] Avoid Invalid relocation and section conflict on bsd. With recent changes I got: /usr/lib/crtbegin.o: error: Invalid relocation entry [ 2] '.rela.text' @ 0000007a And: libtcc.o: error: section type conflict: .eh_frame 01 <> 70000001 --- tccelf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tccelf.c b/tccelf.c index 88b4cd57..718d4906 100644 --- a/tccelf.c +++ b/tccelf.c @@ -3169,9 +3169,11 @@ invalid: || 0 == strncmp(sh_name, ".stab", 5)) { if (!s1->do_debug || seencompressed) continue; +#if !(TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD) } else if (0 == strncmp(sh_name, ".eh_frame", 9)) { if (NULL == eh_frame_section) continue; +#endif } else if (sh->sh_type != SHT_PROGBITS && sh->sh_type != SHT_NOTE && @@ -3181,6 +3183,9 @@ invalid: sh->sh_type != SHT_FINI_ARRAY #ifdef TCC_ARM_EABI && sh->sh_type != SHT_ARM_EXIDX +#endif +#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD + && sh->sh_type != SHT_X86_64_UNWIND #endif ) continue; @@ -3195,7 +3200,7 @@ invalid: if (strcmp(s->name, sh_name)) continue; if (sh->sh_type != s->sh_type - && s != eh_frame_section + && strcmp (s->name, ".eh_frame") ) { tcc_error_noabort("section type conflict: %s %02x <> %02x", s->name, sh->sh_type, s->sh_type); goto the_end;