|
|
70f645 |
/*******************************************************************/
|
|
|
eac61a |
/* slibtool: a strong libtool implementation, written in C */
|
|
|
49181b |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
70f645 |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
70f645 |
/*******************************************************************/
|
|
|
70f645 |
|
|
|
2c013f |
#include <fcntl.h>
|
|
|
70f645 |
#include <stdio.h>
|
|
|
70f645 |
#include <slibtool/slibtool.h>
|
|
|
5fac6c |
#include "slibtool_driver_impl.h"
|
|
|
2c013f |
#include "slibtool_dprintf_impl.h"
|
|
|
3d54f3 |
#include "slibtool_errinfo_impl.h"
|
|
|
70f645 |
#include "slibtool_metafile_impl.h"
|
|
|
4b56de |
#include "slibtool_visibility_impl.h"
|
|
|
70f645 |
|
|
|
70f645 |
static int slbt_create_default_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
|
70f645 |
int ret;
|
|
|
2c013f |
int fdout;
|
|
|
70f645 |
const struct slbt_source_version * verinfo;
|
|
|
70f645 |
|
|
|
2c013f |
if ((fdout = openat(
|
|
|
5fac6c |
slbt_driver_fdcwd(dctx),
|
|
|
2c013f |
ectx->ltobjname,
|
|
|
2c013f |
O_RDWR|O_CREAT|O_TRUNC,
|
|
|
2c013f |
0644)) < 0)
|
|
|
6beda1 |
return SLBT_SYSTEM_ERROR(dctx,ectx->ltobjname);
|
|
|
70f645 |
|
|
|
f0270a |
verinfo = slbt_api_source_version();
|
|
|
70f645 |
|
|
|
2c013f |
ret = slbt_dprintf(fdout,
|
|
|
70f645 |
"# libtool compatible object wrapper\n"
|
|
|
70f645 |
"# Generated by %s (slibtool %d.%d.%d)\n"
|
|
|
70f645 |
"# [commit reference: %s]\n\n"
|
|
|
70f645 |
|
|
|
70f645 |
"pic_object='%s'\n"
|
|
|
70f645 |
"non_pic_object='%s'\n",
|
|
|
70f645 |
|
|
|
70f645 |
dctx->program,
|
|
|
70f645 |
verinfo->major,verinfo->minor,verinfo->revision,
|
|
|
70f645 |
verinfo->commit,
|
|
|
70f645 |
|
|
|
70f645 |
(dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
|
|
|
70f645 |
? ectx->lobjname
|
|
|
70f645 |
: "none",
|
|
|
70f645 |
(dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
|
|
|
70f645 |
? ectx->aobjname
|
|
|
70f645 |
: "none");
|
|
|
70f645 |
|
|
|
2c013f |
close(fdout);
|
|
|
2c013f |
|
|
|
6beda1 |
return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0;
|
|
|
70f645 |
}
|
|
|
70f645 |
|
|
|
70f645 |
static int slbt_create_compatible_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
Sebastian Wiedenroth |
ec296a |
int ret;
|
|
|
c5f4f4 |
int fdout;
|
|
Sebastian Wiedenroth |
ec296a |
const struct slbt_source_version * verinfo;
|
|
Sebastian Wiedenroth |
ec296a |
|
|
|
c5f4f4 |
if ((fdout = openat(
|
|
|
5fac6c |
slbt_driver_fdcwd(dctx),
|
|
|
c5f4f4 |
ectx->ltobjname,
|
|
|
c5f4f4 |
O_RDWR|O_CREAT|O_TRUNC,
|
|
|
c5f4f4 |
0644)) < 0)
|
|
|
6beda1 |
return SLBT_SYSTEM_ERROR(dctx, ectx->ltobjname);
|
|
Sebastian Wiedenroth |
ec296a |
|
|
|
f0270a |
verinfo = slbt_api_source_version();
|
|
Sebastian Wiedenroth |
ec296a |
|
|
|
c5f4f4 |
ret = slbt_dprintf(fdout,
|
|
Sebastian Wiedenroth |
ec296a |
"# %s - a libtool object file\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# Generated by %s (slibtool %d.%d.%d)\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# [commit reference: %s]\n"
|
|
Sebastian Wiedenroth |
ec296a |
"#\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# Please DO NOT delete this file!\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# It is necessary for linking the library.\n\n"
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
"# Name of the PIC object.\n"
|
|
Sebastian Wiedenroth |
ec296a |
"pic_object='%s'\n\n"
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
"# Name of the non-PIC object\n"
|
|
Sebastian Wiedenroth |
ec296a |
"non_pic_object='%s'\n",
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
ectx->ltobjname,
|
|
Sebastian Wiedenroth |
ec296a |
dctx->program,
|
|
Sebastian Wiedenroth |
ec296a |
verinfo->major,verinfo->minor,verinfo->revision,
|
|
Sebastian Wiedenroth |
ec296a |
verinfo->commit,
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
(dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
|
|
Sebastian Wiedenroth |
ec296a |
? ectx->lobjname
|
|
Sebastian Wiedenroth |
ec296a |
: "none",
|
|
Sebastian Wiedenroth |
ec296a |
(dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
|
|
Sebastian Wiedenroth |
ec296a |
? ectx->aobjname
|
|
Sebastian Wiedenroth |
ec296a |
: "none");
|
|
Sebastian Wiedenroth |
ec296a |
|
|
|
c5f4f4 |
close(fdout);
|
|
|
c5f4f4 |
|
|
|
6beda1 |
return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0;
|
|
|
70f645 |
}
|
|
|
70f645 |
|
|
|
4b56de |
slbt_hidden int slbt_create_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
|
70f645 |
if (dctx->cctx->drvflags & SLBT_DRIVER_LEGABITS)
|
|
|
70f645 |
return slbt_create_compatible_object_wrapper(dctx,ectx);
|
|
|
70f645 |
else
|
|
|
70f645 |
return slbt_create_default_object_wrapper(dctx,ectx);
|
|
|
70f645 |
}
|