X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=3B8eow/ahfzOymV7qP6j0ila34exnIq9FebCBGrmc9Q=; b=dK9fm4ccJew9sMxLqO9kCUzGghCeZykYbMPj4YjzSngLrzIw0r4oP3udtRUn0HMm3M HG0nDQG1Pw7X+2M8Aqu7dflbOK1whIS/nJYUh6JycI41DQB0mFX1IYf5bWwc4I6Hx1BS dywP/BJJfN8hD41iB/cX37aC4LS+0cYWEBKDYJoBNcp96oUgIbmKx+DSLOtZEg1Sbxbl mrqUVyVLsZtQu8yZ/0aqzxyoGE5p+rfzWK6sFcl1bK6oqrdClnkdCjSfatIxoW2SoqgG pRNfHaNCM5LLQTFq+Z3oNLQaTemci0Yxkh8RRQUC/BuZqj/xLVwZUZgwCMo7wfAHtbMk whbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3B8eow/ahfzOymV7qP6j0ila34exnIq9FebCBGrmc9Q=; b=znNgutfQ+H7+upGYl5DEcT/zaZFpgUuy+Zqce3Yul6TMOsFgrSBbIdAV1iQrqXb7SI klYeKEKMweP25Tt5JEy2r552RSJCY0iKAsvYYUt9Z4f12NotvlWWs03OFNTwvuM21vgD kmVkE/BktyNWGRzfAqIde/oXowWmO0gnVpu+boa9jNhgANsjd52QC7BybPK3MpKmHAvg GQ65gzUo5RCM4bj6TvdTLjXHnXwEmUeLkPyhsQoT8I8sLZepN46Bf9ovqGgdUOfbjSfl qVJgVEQsx+S+aY5u471XrQsn7VCjWlKYr3lRYjqhTwOEGZ+gWN5qdGQgm/r5cYt7Jat5 bBFw== X-Gm-Message-State: AO0yUKVHmygIpUSPGzBJp0APE9hgyGXVLo6ft4ZORZ6R1st3Rl35SmpJ nAqXTsbx09V2LP/dlTISCgPm1nPO2Pb0khpj7qmO8bbg X-Google-Smtp-Source: AK7set+jhyrAHhFtB1H0bJSeiWdTw2jlI+leHxSxxeOIGV3p7I1GG0xOATHm8uSKB1JOa2OJILHVoqkNe3QAAvSR+rE= X-Received: by 2002:a5d:5b0b:0:b0:2bf:bc64:bb40 with SMTP id bx11-20020a5d5b0b000000b002bfbc64bb40mr353103wrb.34.1674996359716; Sun, 29 Jan 2023 04:45:59 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Sun, 29 Jan 2023 15:45:58 +0300 Message-ID: Subject: Re: [PATCH v3] dxe3gen: invoke ld/as via gcc To: djgpp AT delorie DOT com Content-Type: text/plain; charset="UTF-8" Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk How about the following suggestion? Index: dxe3gen.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v retrieving revision 1.27 diff -u -p -r1.27 dxe3gen.c --- dxe3gen.c 28 Jan 2023 14:10:03 -0000 1.27 +++ dxe3gen.c 29 Jan 2023 12:41:30 -0000 @@ -19,6 +19,7 @@ otherwise the exit code of GNU ld is returned */ +#include #include #include #include @@ -204,7 +205,7 @@ #define IS_SLASH(path) (((path) == '/') || ((path) == '\\')) #define IS_DIR_SEPARATOR(path) (IS_SLASH(path) || ((path) == ':')) -#define NUMBER_OF_LINKER_ARGS 10 +#define NUMBER_OF_LINKER_ARGS 12 #define NUMBER_OF_ADDITIONAL_LOADED_LIBS 0 #define IS_VALID_CIE(id) ((id) == 0) @@ -465,6 +466,25 @@ static void process_env(void) } +static char libgcc_dir[PATH_MAX]; +static void read_libgccdir(void) +{ + char *ptr; + FILE *p; + + sprintf(libgcc_dir, "%s -print-libgcc-file-name", dxe_cc); + p = popen(libgcc_dir,"r"); + memset(libgcc_dir, 0, sizeof(libgcc_dir)); + if (!p) return; + while (fread(libgcc_dir, 1, sizeof(libgcc_dir), p) > 0) { + /**/; + } + pclose(p); + ptr = strrchr(libgcc_dir, '\\'); + if (!ptr) ptr = strrchr(libgcc_dir, '/'); + if (ptr) *ptr = '\0'; +} + /* Desc: process command line args * * In : no of arguments, argument list, ptr to store linker args @@ -481,6 +501,12 @@ static void process_args(int argc, char fprintf(stderr, "Error: neither DXE_LD_LIBRARY_PATH nor DJDIR are set in environment\n"); exit(1); } + read_libgccdir(); + if (!libgcc_dir[0]) + { + fprintf(stderr, "Error: failed determining libgcc directory\n"); + exit(1); + } new_argv[0] = dxe_ld; new_argv[1] = "-X"; @@ -490,8 +516,10 @@ static void process_args(int argc, char new_argv[5] = TEMP_O_FILE; new_argv[6] = "-L"; new_argv[7] = libdir; - new_argv[8] = "-T"; - new_argv[9] = dxe_sc; + new_argv[8] = "-L"; + new_argv[9] = libgcc_dir; + new_argv[10] = "-T"; + new_argv[11] = dxe_sc; if (!strcmp(base_name(argv[0]), "dxegen")) /* invoked as `dxegen' */