|
|
f4ad24 |
/*******************************************************************/
|
|
|
eac61a |
/* slibtool: a strong libtool implementation, written in C */
|
|
|
f4ad24 |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
f4ad24 |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
f4ad24 |
/*******************************************************************/
|
|
|
f4ad24 |
|
|
|
f4ad24 |
#include <time.h>
|
|
|
f4ad24 |
#include <locale.h>
|
|
|
f4ad24 |
#include <regex.h>
|
|
|
f4ad24 |
#include <inttypes.h>
|
|
|
f4ad24 |
#include <slibtool/slibtool.h>
|
|
|
f4ad24 |
#include <slibtool/slibtool_output.h>
|
|
|
f4ad24 |
#include "slibtool_driver_impl.h"
|
|
|
f4ad24 |
#include "slibtool_dprintf_impl.h"
|
|
|
f4ad24 |
#include "slibtool_errinfo_impl.h"
|
|
|
f4ad24 |
#include "slibtool_pecoff_impl.h"
|
|
|
f4ad24 |
#include "slibtool_ar_impl.h"
|
|
|
f4ad24 |
|
|
|
f4ad24 |
/********************************************************/
|
|
|
f4ad24 |
/* Clone a symbol list that could be used by a build */
|
|
|
f4ad24 |
/* system for code generation or any other purpose. */
|
|
|
f4ad24 |
/********************************************************/
|
|
|
f4ad24 |
|
|
|
f4ad24 |
static int slbt_util_output_symfile_impl(
|
|
|
f4ad24 |
const struct slbt_driver_ctx * dctx,
|
|
|
f4ad24 |
const struct slbt_symlist_ctx * sctx,
|
|
|
f4ad24 |
int fdout)
|
|
|
f4ad24 |
{
|
|
|
f4ad24 |
bool fcoff;
|
|
|
f4ad24 |
const char ** symv;
|
|
|
f4ad24 |
const char ** symstrv;
|
|
|
f4ad24 |
|
|
|
f4ad24 |
fcoff = slbt_host_objfmt_is_coff(dctx);
|
|
|
f4ad24 |
|
|
|
f4ad24 |
symstrv = sctx->symstrv;
|
|
|
f4ad24 |
|
|
|
f4ad24 |
for (symv=symstrv; *symv; symv++)
|
|
|
f4ad24 |
if (!fcoff || slbt_is_strong_coff_symbol(*symv))
|
|
|
f4ad24 |
if (slbt_dprintf(fdout,"%s\n",*symv) < 0)
|
|
|
f4ad24 |
return SLBT_SYSTEM_ERROR(dctx,0);
|
|
|
f4ad24 |
|
|
|
f4ad24 |
return 0;
|
|
|
f4ad24 |
}
|
|
|
f4ad24 |
|
|
|
f4ad24 |
|
|
|
f4ad24 |
static int slbt_util_create_symfile_impl(
|
|
|
f4ad24 |
const struct slbt_symlist_ctx * sctx,
|
|
|
f4ad24 |
const char * path,
|
|
|
f4ad24 |
mode_t mode)
|
|
|
f4ad24 |
{
|
|
|
f4ad24 |
int ret;
|
|
|
f4ad24 |
const struct slbt_driver_ctx * dctx;
|
|
|
f4ad24 |
struct slbt_fd_ctx fdctx;
|
|
|
f4ad24 |
int fdout;
|
|
|
f4ad24 |
|
|
|
f4ad24 |
dctx = (slbt_get_symlist_ictx(sctx))->dctx;
|
|
|
f4ad24 |
|
|
|
f4ad24 |
if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0)
|
|
|
f4ad24 |
return SLBT_NESTED_ERROR(dctx);
|
|
|
f4ad24 |
|
|
|
f4ad24 |
if (path) {
|
|
|
f4ad24 |
if ((fdout = openat(
|
|
|
f4ad24 |
fdctx.fdcwd,path,
|
|
|
f4ad24 |
O_WRONLY|O_CREAT|O_TRUNC,
|
|
|
f4ad24 |
mode)) < 0)
|
|
|
f4ad24 |
return SLBT_SYSTEM_ERROR(dctx,0);
|
|
|
f4ad24 |
} else {
|
|
|
f4ad24 |
fdout = fdctx.fdout;
|
|
|
f4ad24 |
}
|
|
|
f4ad24 |
|
|
|
f4ad24 |
ret = slbt_util_output_symfile_impl(
|
|
|
f4ad24 |
dctx,sctx,fdout);
|
|
|
f4ad24 |
|
|
|
f4ad24 |
if (path) {
|
|
|
f4ad24 |
close(fdout);
|
|
|
f4ad24 |
}
|
|
|
f4ad24 |
|
|
|
f4ad24 |
return ret;
|
|
|
f4ad24 |
}
|
|
|
f4ad24 |
|
|
|
f4ad24 |
|
|
|
f4ad24 |
int slbt_util_create_symfile(
|
|
|
f4ad24 |
const struct slbt_symlist_ctx * sctx,
|
|
|
f4ad24 |
const char * path,
|
|
|
f4ad24 |
mode_t mode)
|
|
|
f4ad24 |
{
|
|
|
f4ad24 |
return slbt_util_create_symfile_impl(sctx,path,mode);
|
|
|
f4ad24 |
}
|