summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-03-16 04:21:31 +0000
committermidipix <writeonce@midipix.org>2024-03-16 15:31:41 +0000
commita9bad5065550adfde1e267ab34d7a90472fe034d (patch)
treef71452960d289ec8f0862a89efb044a8e91b8ed8 /src/util
parente990e39ea0dbab989d1d6de47a2998afe9fac55b (diff)
downloadslibtool-a9bad5065550adfde1e267ab34d7a90472fe034d.tar.bz2
slibtool-a9bad5065550adfde1e267ab34d7a90472fe034d.tar.xz
slbt_util_create_mapfile(): properly set weak aliases of strong symbols.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/slbt_create_mapfile.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/util/slbt_create_mapfile.c b/src/util/slbt_create_mapfile.c
index 8a9af54..8c03920 100644
--- a/src/util/slbt_create_mapfile.c
+++ b/src/util/slbt_create_mapfile.c
@@ -32,8 +32,11 @@ static int slbt_util_output_mapfile_impl(
{
bool fcoff;
bool fmach;
+ const char * dot;
+ const char * mark;
const char ** symv;
const char ** symstrv;
+ char strbuf[4096];
fcoff = slbt_host_objfmt_is_coff(dctx);
fmach = slbt_host_objfmt_is_macho(dctx);
@@ -52,17 +55,27 @@ static int slbt_util_output_mapfile_impl(
symstrv = sctx->symstrv;
for (symv=symstrv; *symv; symv++) {
- if (!fcoff || slbt_is_strong_coff_symbol(*symv)) {
- if (fcoff) {
- if (slbt_dprintf(fdout,"%s\n",*symv) < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
- } else if (fmach) {
- if (slbt_dprintf(fdout,"_%s\n",*symv) < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
- } else {
- if (slbt_dprintf(fdout,"\t\t%s;\n",*symv) < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
- }
+ if (fcoff && slbt_is_strong_coff_symbol(*symv)) {
+ if (slbt_dprintf(fdout,"%s\n",*symv) < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+
+ } else if (fcoff && !strncmp(*symv,".weak.",6)) {
+ mark = &(*symv)[6];
+ dot = strchr(mark,'.');
+
+ strncpy(strbuf,mark,dot-mark);
+ strbuf[dot-mark] = '\0';
+
+ if (slbt_dprintf(fdout," %s = %s\n",strbuf,++dot) < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+
+ } else if (fmach) {
+ if (slbt_dprintf(fdout,"_%s\n",*symv) < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+
+ } else {
+ if (slbt_dprintf(fdout,"\t\t%s;\n",*symv) < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
}
}