[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] likner script parser - support relative/short file na
From: |
Thomas Preud'homme |
Subject: |
Re: [Tinycc-devel] likner script parser - support relative/short file names? |
Date: |
Mon, 19 Sep 2011 19:30:09 +0200 |
User-agent: |
KMail/1.13.7 (Linux/3.0.0-1-amd64; KDE/4.6.5; x86_64; ; ) |
Le lundi 19 septembre 2011 18:49:32, address@hidden a écrit :
> Hello,
>
> I had to apply the following patch to be able to use my uclibc instance
> which contains relative library file names in the libc.so linker script.
>
> It does not work otherwise, tcc complains about unrecognized file format.
> (It worked however if the script contained only absolute file names.)
>
> The patch:
> ----
> --- tccelf.c.ori2 2011-09-19 13:20:59.000000000 +0200
> +++ tccelf.c 2011-09-19 14:33:30.000000000 +0200
> @@ -3005,7 +3005,7 @@
> } else {
> /* TODO: Implement AS_NEEDED support. Ignore it for now */
> if (!as_needed) {
> - ret = ld_add_file(s1, filename, libname);
> + ret = tcc_add_dll(s1, filename, 0);
> if (ret)
> goto lib_parse_error;
> if (group) {
> ----
>
> The linker script in question was
> ..../lib/libc.so:
> ----
> /* GNU ld script
> * Use the shared library, but some functions are only in
> * the static library, so try that secondarily. */
> OUTPUT_FORMAT("elf32-i386", "elf32-i386",
> "elf32-i386")
> GROUP ( libc.so.0 uclibc_nonshared.a AS_NEEDED ( ld-uClibc.so.0 ) )
> ----
Good catch.
>
> Hope this change makes sense.
It does but it's incomplete. You should tcc_add_dll after tcc_add_file_internal
because each file must be searched first in current directory and then in the
library search path according to [1]. Hence you should modify ld_add_file to
use tcc_add_dll instead of if (filename_to_libname()) tcc_add_library. Hence
you can also remove filename_to_libname function altogether.
I've just noticed the function should be a bit more constraint to reject files
like AS_NEEDED(AS_NEEDED(…)). Also libname_to_filename should always return .a
for non PE systems, still according to [1]. But don't bother to do this part,
I'll do it myself one day.
[1] http://www.delorie.com/gnu/docs/binutils/ld_12.html
>
> Regards,
> Rune
Thanks a lot.
Thomas Preud'homme
>
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
signature.asc
Description: This is a digitally signed message part.