X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX18DZmRDhHUDrj01klqcpvX+ZHKOeoRet7Qmtcuxms H/diFcTEELJDNb From: Juan Manuel Guerrero To: djgpp-workers AT delorie DOT com Subject: Re: dxe and gcc 4.6.1 difficulties. Date: Wed, 21 Dec 2011 13:34:09 +0100 User-Agent: KMail/1.9.10 References: <201108141841 DOT 15711 DOT juan DOT guerrero AT gmx DOT de> <4EF02233 DOT 4070004 AT iki DOT fi> <201112202253 DOT 56277 DOT juan DOT guerrero AT gmx DOT de> In-Reply-To: <201112202253.56277.juan.guerrero@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201112211334.09427.juan.guerrero@gmx.de> X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com Am Dienstag, 20. Dezember 2011 schrieb Juan Manuel Guerrero: > Am Dienstag, 20. Dezember 2011 schrieb Andris Pavenis: [snip] To minimize the changes to dxe3gen I have decided to drop the use of the LD_PRELOAD environment variable. In this final version, it will be checked if the object file contains an .eh_frame segement/symbol and only if this is the case libc.a will be automatically added to the linker options. This will make sure that the __[de]register_frame_info symbols will be resolved when the DXE modul is build. If no one objects I will commit this change ASAP so I can continue porting Lua. Regards, Juan M. Guerrero 2011-12-21 Juan Manuel Guerrero * src/dxe/dxe3gen.c: If an object file has an eh frame always link against libc to resolve __[de]register_frame_info symbols. * src/libc/crt0/rfinfo.c: Define __deregister_frame_info. * src/docs/kb/wc204.txi: dxe3gen specific info added. diff -aprNU5 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi --- djgpp.orig/src/docs/kb/wc204.txi 2011-10-02 02:39:40 +0000 +++ djgpp/src/docs/kb/wc204.txi 2011-12-21 13:11:58 +0000 @@ -1232,5 +1232,11 @@ Functions @code{flushdc}, @code{dosexec} @code{_rename} now check that the used LFN driver supplies the required @code{0x71} function from the @code{Windows 95} long filename functions API by inspecting the content of the @code{AX} register after return from the API function call. Depending on the function type, the function will ignore, fail or fall back on the corresponding SFN API function if the LFN API function is not provided by the LFN driver used. + +@pindex dxe3gen AT r{, resolving __[de]register_frame_info symbols in DXE moduls} +When @code{dxe3gen} detects that one of the object files that shall be linked +into a @acronym{DXE} modul contains a @code{.eh_frame} section it automatically +links the modul with @code{libc.a} to resolve both @code{__register_frame_info} +and @code{__deregister_frame_info} symbols. diff -aprNU5 djgpp.orig/src/dxe/dxe3gen.c djgpp/src/dxe/dxe3gen.c --- djgpp.orig/src/dxe/dxe3gen.c 2011-12-21 11:20:36 +0000 +++ djgpp/src/dxe/dxe3gen.c 2011-12-21 13:11:32 +0000 @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2003 Borca Daniel * Copyright (C) 2000 Andrew Zabolotny * Partly based on work by Charles Sandmann and DJ Delorie. * Usage of this library is not restricted in any way. @@ -38,10 +39,13 @@ #define TEMP_O_FILE TEMP_BASE".o" #define TEMP_S_FILE TEMP_BASE".s" #define VALID_RELOC(r) ((r.r_type != RELOC_REL32) && (r.r_symndx != (ULONG32)-1)) +#define NUMBER_OF_LINKER_ARGS 10 +#define NUMBER_OF_ADDITIONAL_LOADED_LIBS 1 + typedef enum { FALSE = 0, TRUE = !FALSE } BOOL; @@ -123,10 +127,31 @@ static struct { NULL }; +/* Desc: replaces backslash with slash in a path + * + * In : path string + * Out : path string + * + * Note: - + */ +static void canonicalize_path(char *path) +{ + if (path) + { + char *scan = path; + + for (; *scan; scan++) + if (*scan == '\\') + *scan = '/'; + } +} + + + /* Desc: remove temporary files * * In : - * Out : - * @@ -229,20 +254,21 @@ static void display_help (void) static void process_args (int argc, char *argv[], const char *new_argv[]) { static char libdir[FILENAME_MAX]; char *p; int i; - int new_argc = 10; + int new_argc = NUMBER_OF_LINKER_ARGS; p = getenv("DXE_LD_LIBRARY_PATH"); if (p) strcpy(libdir, p); else { p = getenv("DJDIR"); if (p) { strcpy(libdir, p); strcat(libdir, "/lib"); + canonicalize_path(libdir); } else { fprintf(stderr, "Error: neither DXE_LD_LIBRARY_PATH nor DJDIR are set in environment\n"); exit(1); } } @@ -335,11 +361,11 @@ static void process_args (int argc, char new_argv[new_argc++] = argv[i]; dot = strrchr(argv[i], '.'); if (dot) { if (!strcasecmp(dot, ".o") || !strcasecmp(dot, ".a")) { opt.objcount++; - } else if (!strcasecmp(dot, ".dxe")) { + } else if (!strcasecmp(dot, ".dxe") || !strcasecmp(dot, ".so")) { opt.dxefile = argv[i]; } } } } @@ -469,10 +495,16 @@ static FILE *run_ld (const char *argv[], f = fopen(TEMP_BASE"f.o", "wb"); fwrite(finis[fini - 1].data, finis[fini - 1].size, 1, f); fclose(f); argv[i++] = TEMP_BASE"f.o"; } + + /* Link TEMP_BASE"i.o" and/or TEMP_BASE"f.o" against libc.a + * to resolve the __[de]register_frame_info symbols. + */ + if ((init > 1) || (fini > 1)) + argv[i++] = "/dev/env/DJDIR/lib/libc.a"; /* libc will resolve __[de]register_frame_* symbols. */ argv[i] = NULL; rv = myspawn(argv); if (init > 0) { @@ -1111,18 +1143,18 @@ int main (int argc, char **argv) int rv; const char **new_argv; progname = argv[0]; /* Prepare the command line for ld */ - new_argv = (const char **)malloc((argc - 1 + 11 + 2) * sizeof(char *)); + new_argv = (const char **)malloc((argc - 1 + NUMBER_OF_LINKER_ARGS + NUMBER_OF_ADDITIONAL_LOADED_LIBS + 2 + 1) * sizeof(char *)); process_args(argc, argv, new_argv); if (opt.showdep || opt.showexp || opt.showunres) { for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { char *dot = strchr(argv[i], '.'); - if (dot && !strcasecmp(dot, ".dxe")) { + if (dot && (!strcasecmp(dot, ".dxe") || !strcasecmp(dot, ".so"))) { if ((rv = show_symbols(argv[i])) != 0) { return rv; } } } diff -aprNU5 djgpp.orig/src/libc/crt0/rfinfo.c djgpp/src/libc/crt0/rfinfo.c --- djgpp.orig/src/libc/crt0/rfinfo.c 2011-12-21 11:20:36 +0000 +++ djgpp/src/libc/crt0/rfinfo.c 2011-12-21 11:37:34 +0000 @@ -1,7 +1,14 @@ +/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -void __register_frame_info(void *begin __attribute__((unused)), - void *object __attribute__((unused))); -void __register_frame_info(void *begin __attribute__((unused)), - void *object __attribute__((unused))) +void __register_frame_info(const void *begin __attribute__((unused)), + const void *object __attribute__((unused))); +void __register_frame_info(const void *begin __attribute__((unused)), + const void *object __attribute__((unused))) { } + + +void __deregister_frame_info(const void *begin __attribute__((unused))); +void __deregister_frame_info(const void *begin __attribute__((unused))) + { + }