Le lundi 1 août 2011 19:22:19, grischka a écrit : > Thomas Preud'homme wrote: > > Solution 1: > Yes. Good luck ;)
Done (see 76adc57). I have a "solution" for the elf_interpreter in Debian but it's more invasive (~10 lines of code added) and only suited for native compilers (which is fine in Debian since only native tcc is packaged). But it doesn't allow to generate a program for a system non multiarch if tcc is on a multiarch system (or the reverse), which is more annoying. Anyway, I attached it in case you're curious and just to make you cry ;-) Note that it would be better to use tcc_add_file_noerror for libgcc_s.so.1 and crtn.o as well but we'd need to be able to not export the symbol in libtcc.a. A file included in both libtcc.c and tccelf.c containing this function would do it but I thought it would be overkill. So about elf_interp, I wanted to support both path but of course it's impossible. What is different from the other paths is that it's about the compiled programs, not about tcc. Hence, even if tcc is compiled for a multiarchified system, we want to be able to generate code either for a multiarch system or not. Maybe a new switch is necessary for tcc? Or worse, we could consider doing two tcc for each system, one which generate a multiarch elf interpreter, one which generate a simple elf interpreter. This way, however multiarch or not is tcc, we can generate multiarch aware programs or not. I really need suggestion for this :) > > --- grischka
diff --git a/tccelf.c b/tccelf.c
index f58ae83..946d081 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1323,19 +1323,25 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1)
}
/* name of ELF interpreter */
+#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
+#define MULTIARCH_TRIPLET CONFIG_TCC_MULTIARCH_TRIPLET
+#else
+#define MULTIARCH_TRIPLET ""
+#endif
#if defined __FreeBSD__
-static const char elf_interp[] = "/libexec/ld-elf.so.1";
+static char elf_interp[] = "/libexec/"MULTIARCH_TRIPLET"/ld-elf.so.1";
#elif defined __FreeBSD_kernel__
-static char elf_interp[] = CONFIG_TCC_LDDIR"/ld.so.1";
+static char elf_interp[] = CONFIG_TCC_LDDIR"/"MULTIARCH_TRIPLET"/ld.so.1";
#elif defined TCC_ARM_EABI
-static const char elf_interp[] = CONFIG_TCC_LDDIR"/ld-linux.so.3";
+static char elf_interp[] = CONFIG_TCC_LDDIR"/"MULTIARCH_TRIPLET"/ld-linux.so.3";
#elif defined(TCC_TARGET_X86_64)
-static const char elf_interp[] = CONFIG_TCC_LDDIR"/ld-linux-x86-64.so.2";
+static char elf_interp[] = CONFIG_TCC_LDDIR"/"MULTIARCH_TRIPLET"/ld-linux-x86-64.so.2";
#elif defined(TCC_UCLIBC)
-static const char elf_interp[] = CONFIG_TCC_LDDIR"/ld-uClibc.so.0";
+static char elf_interp[] = CONFIG_TCC_LDDIR"/"MULTIARCH_TRIPLET"/ld-uClibc.so.0";
#else
-static const char elf_interp[] = CONFIG_TCC_LDDIR"/ld-linux.so.2";
+static char elf_interp[] = CONFIG_TCC_LDDIR"/"MULTIARCH_TRIPLET"/ld-linux.so.2";
#endif
+#undef MULTIARCH_TRIPLET
static void tcc_output_binary(TCCState *s1, FILE *f,
const int *section_order)
@@ -1478,8 +1484,25 @@ static int elf_output_file(TCCState *s1, const char *filename)
char *ptr;
/* allow override the dynamic loader */
const char *elfint = getenv("LD_SO");
- if (elfint == NULL)
+ if (elfint == NULL) {
+#ifdef CONFIG_TCC_MULTIARCH_SUBDIR
+ int ret;
+
+ ret = tcc_open(s1, elf_interp);
+ if(ret >= 0)
+ tcc_close();
+ else {
+ char *base, *p;
+
+ base = tcc_basename(elf_interp);
+ p = base - 1;
+ while (!IS_DIRSEP(p[-1]))
+ --p;
+ pstrcpy(p, strlen(elf_interp), base);
+ }
+#endif
elfint = elf_interp;
+ }
/* add interpreter section only if executable */
interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
interp->sh_addralign = 1;
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
