summaryrefslogtreecommitdiff
path: root/src/arbits
diff options
context:
space:
mode:
Diffstat (limited to 'src/arbits')
-rw-r--r--src/arbits/slbt_archive_mapfile.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/arbits/slbt_archive_mapfile.c b/src/arbits/slbt_archive_mapfile.c
index 976b809..08ef3f9 100644
--- a/src/arbits/slbt_archive_mapfile.c
+++ b/src/arbits/slbt_archive_mapfile.c
@@ -15,6 +15,15 @@
#include "slibtool_errinfo_impl.h"
#include "slibtool_ar_impl.h"
+/********************************************************/
+/* Generate a symbol mapfile (aka version script) that */
+/* could be passed to the host linker. */
+/* */
+/* Since the symbol list is directly derived from the */
+/* archive's armap member, prepending symbol names with */
+/* an underscore (where relevant) is not necessary. */
+/********************************************************/
+
static int slbt_ar_output_mapfile_impl(
const struct slbt_driver_ctx * dctx,
struct slbt_archive_meta_impl * mctx,
@@ -22,6 +31,7 @@ static int slbt_ar_output_mapfile_impl(
{
bool fsort;
bool fcoff;
+ bool fmach;
const char * regex;
const char ** symv;
const char ** symstrv;
@@ -29,10 +39,26 @@ static int slbt_ar_output_mapfile_impl(
regmatch_t pmatch[2] = {{0,0},{0,0}};
fsort = !(dctx->cctx->fmtflags & SLBT_OUTPUT_ARCHIVE_NOSORT);
- fcoff = (mctx->ofmtattr == AR_OBJECT_ATTR_COFF);
- if (slbt_dprintf(fdout,"{\n" "\t" "global:\n") < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
+ fmach = !strcmp(dctx->cctx->host.flavor,"darwin");
+ fmach = fmach || (mctx->ofmtattr & AR_OBJECT_ATTR_MACHO);
+
+ fcoff = !strcmp(dctx->cctx->host.flavor,"midipix");
+ fcoff = fcoff || !strcmp(dctx->cctx->host.flavor,"cygwin");
+ fcoff = fcoff || !strcmp(dctx->cctx->host.flavor,"mingw");
+ fcoff = fcoff || !strcmp(dctx->cctx->host.flavor,"msys2");
+ fcoff = fcoff || (mctx->ofmtattr & AR_OBJECT_ATTR_COFF);
+
+ if (fcoff) {
+ if (slbt_dprintf(fdout,"EXPORTS\n") < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ } else if (fmach) {
+ if (slbt_dprintf(fdout,"# export_list, armap underscores\n") < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ } else {
+ if (slbt_dprintf(fdout,"{\n" "\t" "global:\n") < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ }
if (fsort && !mctx->mapstrv)
if (slbt_update_mapstrv(dctx,mctx) < 0)
@@ -46,17 +72,26 @@ static int slbt_ar_output_mapfile_impl(
symstrv = fsort ? mctx->mapstrv : mctx->symstrv;
- for (symv=symstrv; *symv; symv++)
- if (!fcoff || strncmp(*symv,"__imp_",6))
- if (!regex || !regexec(&regctx,*symv,1,pmatch,0))
- if (slbt_dprintf(fdout,"\t\t%s;\n",*symv) < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
+ for (symv=symstrv; *symv; symv++) {
+ if (!fcoff || strncmp(*symv,"__imp_",6)) {
+ if (!regex || !regexec(&regctx,*symv,1,pmatch,0)) {
+ if (fcoff || 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 (regex)
regfree(&regctx);
- if (slbt_dprintf(fdout,"\n\t" "local:\n" "\t\t*;\n" "};\n") < 0)
- return SLBT_SYSTEM_ERROR(dctx,0);
+ if (!fcoff && !fmach)
+ if (slbt_dprintf(fdout,"\n\t" "local:\n" "\t\t*;\n" "};\n") < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
return 0;
}