summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-04-27 20:17:37 +0000
committermidipix <writeonce@midipix.org>2024-04-27 20:21:10 +0000
commit932769f0aa62e4507bd9de216c5e9a670affe5a4 (patch)
tree0b8a7ace36100fd865800782bad6bb1b18c557d3 /src
parent3f97b6f6c344500e0005063d1580afdb32c333e4 (diff)
downloadmdso-932769f0aa62e4507bd9de216c5e9a670affe5a4.tar.bz2
mdso-932769f0aa62e4507bd9de216c5e9a670affe5a4.tar.xz
mdso_create_implib_sources(): eliminate the use of sprintf().
Diffstat (limited to 'src')
-rw-r--r--src/util/mdso_create_implib_sources.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/util/mdso_create_implib_sources.c b/src/util/mdso_create_implib_sources.c
index f7cf81b..5d002d5 100644
--- a/src/util/mdso_create_implib_sources.c
+++ b/src/util/mdso_create_implib_sources.c
@@ -10,21 +10,51 @@
#include <mdso/mdso.h>
#include "mdso_driver_impl.h"
+#include "mdso_hexfmt_impl.h"
#include "mdso_errinfo_impl.h"
-static void mdso_init_asmname(char * buf, const char * fmt, const char * str)
+static void mdso_init_symentry(char * ch, const char * str)
{
- char hexstr[24];
- long long unsigned int crc64;
-
- if (strlen(str) + strlen(fmt) > (PATH_MAX - 1)) {
- crc64 = mdso_crc64_mbstr((const unsigned char *)str,0);
- sprintf(hexstr,"%llx",crc64);
- sprintf(buf,fmt,hexstr);
- } else
- sprintf(buf,fmt,str);
+ uint64_t crc64;
+ unsigned slen = 11;
+
+ ch[0] = '.';
+ ch++;
+
+ if (strlen(str) > (PATH_MAX - slen - 1)) {
+ crc64 = mdso_crc64_mbstr((unsigned char *)str,0);
+ mdso_write_hex_64(ch,crc64);
+ ch = &ch[16];
+ } else {
+ for (; *str; )
+ *ch++ = *str++;
+ }
+
+ memcpy(ch,"_symentry.s",slen);
+ ch[slen] = '\0';
}
+static void mdso_init_dsometa(char * ch, const char * str)
+{
+ uint64_t crc64;
+ unsigned slen = 9;
+
+ memcpy(ch,".dsometa_",slen);
+ ch = &ch[slen];
+
+ if (strlen(str) > (PATH_MAX - slen - 1)) {
+ crc64 = mdso_crc64_mbstr((unsigned char *)str,0);
+ mdso_write_hex_64(ch,crc64);
+ ch = &ch[16];
+ } else {
+ for (; *str; )
+ *ch++ = *str++;
+ }
+
+ ch[0] = '.';
+ ch[1] = 's';
+ ch[2] = '\0';
+}
int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx)
{
struct mdso_unit_ctx * uctx;
@@ -41,7 +71,7 @@ int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx)
return MDSO_NESTED_ERROR(dctx);
for (sym=uctx->syms; *sym; sym++) {
- mdso_init_asmname(asmname,".%s_symentry.s",*sym);
+ mdso_init_symentry(asmname,*sym);
if ((fdout = mdso_create_asmsrc(dctx,asmname)) < 0)
return MDSO_NESTED_ERROR(dctx);
@@ -59,7 +89,7 @@ int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx)
}
/* dsometa */
- mdso_init_asmname(asmname,".dsometa_%s.s",dctx->cctx->libname);
+ mdso_init_dsometa(asmname,dctx->cctx->libname);
if ((fdout = mdso_create_asmsrc(dctx,asmname)) < 0)
return MDSO_NESTED_ERROR(dctx);