summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/mdso_create_asm_source.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/helper/mdso_create_asm_source.c b/src/helper/mdso_create_asm_source.c
index 85aaaba..b152697 100644
--- a/src/helper/mdso_create_asm_source.c
+++ b/src/helper/mdso_create_asm_source.c
@@ -15,22 +15,19 @@
#include "mdso_driver_impl.h"
#include "mdso_errinfo_impl.h"
-FILE * mdso_create_asm_source(
+static FILE * mdso_create_output(
const struct mdso_driver_ctx * dctx,
- const char * asmname)
+ const char * name)
{
struct mdso_driver_ctx_impl * ictx;
uintptr_t addr;
int fdout;
FILE * fout;
- if (!dctx->cctx->dstdir)
- return stdout;
-
addr = (uintptr_t)dctx - offsetof(struct mdso_driver_ctx_impl,ctx);
ictx = (struct mdso_driver_ctx_impl *)addr;
- if ((fdout = openat(ictx->fddst,asmname,
+ if ((fdout = openat(ictx->fddst,name,
O_CREAT|O_TRUNC|O_WRONLY|O_NOCTTY|O_NOFOLLOW,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
MDSO_SYSTEM_ERROR(dctx);
@@ -45,3 +42,25 @@ FILE * mdso_create_asm_source(
return fout;
}
+
+FILE * mdso_create_asm_source(
+ const struct mdso_driver_ctx * dctx,
+ const char * asmname)
+{
+ if (!dctx->cctx->dstdir)
+ return stdout;
+
+ return mdso_create_output(dctx,asmname);
+}
+
+FILE * mdso_create_object(
+ const struct mdso_driver_ctx * dctx,
+ const char * objname)
+{
+ if (!dctx->cctx->dstdir) {
+ MDSO_CUSTOM_ERROR(dctx,MDSO_ERR_INVALID_DSTDIR);
+ return 0;
+ }
+
+ return mdso_create_output(dctx,objname);
+}