From 1443ebb29f38c44a40bf3ce7754b9153b45712e9 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 16 Mar 2024 15:57:31 +0000 Subject: slbt_au_output_symbols(): include weak aliases of strong symbols. --- src/arbits/output/slbt_au_output_symbols.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/arbits/output/slbt_au_output_symbols.c b/src/arbits/output/slbt_au_output_symbols.c index 8d53d77..49d78ae 100644 --- a/src/arbits/output/slbt_au_output_symbols.c +++ b/src/arbits/output/slbt_au_output_symbols.c @@ -28,11 +28,14 @@ static int slbt_au_output_symbols_posix( int fdout; bool fsort; bool fcoff; + const char * dot; + const char * mark; const char * regex; const char ** symv; const char ** symstrv; regex_t regctx; regmatch_t pmatch[2] = {{0,0},{0,0}}; + char strbuf[4096]; fdout = fdctx->fdout; fsort = !(dctx->cctx->fmtflags & SLBT_OUTPUT_ARCHIVE_NOSORT); @@ -50,11 +53,26 @@ static int slbt_au_output_symbols_posix( symstrv = fsort ? mctx->mapstrv : mctx->symstrv; - for (symv=symstrv; *symv; symv++) - if (!fcoff || slbt_is_strong_coff_symbol(*symv)) - if (!regex || !regexec(®ctx,*symv,1,pmatch,0)) + for (symv=symstrv; *symv; symv++) { + if (!fcoff || slbt_is_strong_coff_symbol(*symv)) { + if (!regex || !regexec(®ctx,*symv,1,pmatch,0)) { if (slbt_dprintf(fdout,"%s\n",*symv) < 0) return SLBT_SYSTEM_ERROR(dctx,0); + } + + /* coff weak symbols: expsym = .weak.alias.strong */ + } else if (fcoff && !strncmp(*symv,".weak.",6)) { + mark = &(*symv)[6]; + dot = strchr(mark,'.'); + + strncpy(strbuf,mark,dot-mark); + strbuf[dot-mark] = '\0'; + + if (!regex || !regexec(®ctx,strbuf,1,pmatch,0)) + if (slbt_dprintf(fdout,"%s\n",strbuf) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + } + } if (regex) regfree(®ctx); -- cgit v1.2.3