@@ -265,12 +265,9 @@ class MyFrontendAction: public clang::ASTFrontendAction {
265
265
if (prefixable (token.getLocation ())) {
266
266
std::string name = pp.getSpelling (token);
267
267
m_identifiers.insert (name);
268
- if (name == " SHLIB_VERSION_NUMBER " ) {
268
+ if (name == " OPENSSL_VERSION_MAJOR " ) {
269
269
const auto &token = directive->getMacroInfo ()->getReplacementToken (0 );
270
270
m_shlibversion = std::string (token.getLiteralData (), token.getLength ());
271
- // Remove the quotation marks.
272
- m_shlibversion = m_shlibversion.substr (1 , m_shlibversion.size () - 1 );
273
- m_shlibversion.pop_back ();
274
271
}
275
272
}
276
273
}
@@ -440,9 +437,10 @@ void MyFrontendAction::EndSourceFileAction() {
440
437
std::map<std::string,std::vector<Function>> funcmap;
441
438
442
439
for (const auto &f : m_functions) {
443
- std::string header = f.getHeader (srcmgr);
440
+ std::filesystem::path header = f.getHeader (srcmgr);
441
+ header = header.lexically_relative (opt::incdir ());
444
442
if (funcmap.find (header) == funcmap.end ()) {
445
- hstr << " #include \" " << header <<" \" " << std::endl;
443
+ hstr << " #include \" " << header. string () <<" \" " << std::endl;
446
444
}
447
445
funcmap[header].push_back (f);
448
446
}
@@ -474,9 +472,11 @@ void MyFrontendAction::EndSourceFileAction() {
474
472
std::ofstream cstr (opt::cfile ());
475
473
476
474
cstr << " //" << std::endl << " // THIS FILE IS GENERATED BY THE PREFIXER TOOL DO NOT EDIT" << std::endl << " //" << std::endl
475
+ << " #include <link.h>" << std::endl
477
476
<< " #include <dlfcn.h>" << std::endl
478
477
<< " #include <errno.h>" << std::endl
479
478
<< " #include <assert.h>" << std::endl
479
+ << " #include \" ossl_dlfcn.h\" " << std::endl
480
480
<< " #include \" " << opt::prefix << " .h\" " << std::endl
481
481
<< std::endl
482
482
<< " #define LIBCRYPTO_SO \" libcrypto.so" << (m_shlibversion.size () ? " ." + m_shlibversion : " " ) << " \" " << std::endl
@@ -495,19 +495,20 @@ void MyFrontendAction::EndSourceFileAction() {
495
495
<< " const char *s = symbol + " << opt::prefix.size () + 1 << " ;" << std::endl
496
496
<< " if ((result = dlsym(libcrypto, s)) != NULL) return result;" << std::endl
497
497
<< " if((result = dlsym(libssl, s)) != NULL) return result;" << std::endl
498
- << " //fprintf(stderr, \" dlsym(%s) : %s\\ n\" , s, dlerror());" << std::endl
499
- << " //exit(ELIBACC);" << std::endl
500
498
<< " return NULL;" << std::endl
501
499
<< " }" << std::endl
502
500
<< std::endl
501
+ << " void " << opt::prefix << " _init_debug(void);" << std::endl
502
+ << std::endl
503
503
<< " static void " << opt::prefix << " _init(void) {" << std::endl
504
- << " if((libcrypto = dlopen(LIBCRYPTO_SO, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND)) == NULL) {" << std::endl
505
- << " fprintf(stderr, \" dlopen(%s) : %s\\ n\" , LIBCRYPTO_SO, dlerror());" << std::endl
504
+ << " " << opt::prefix << " _init_debug();" << std::endl
505
+ << " if((libcrypto = ossl_dlopen(LIBCRYPTO_SO)) == NULL) {" << std::endl
506
+ << " fprintf(stderr, \" dlopen(%s) failed after searching multiple paths: %s\\ n\" , LIBCRYPTO_SO, dlerror());" << std::endl
506
507
<< " exit(ELIBACC);" << std::endl
507
508
<< " }" << std::endl
508
509
<< std::endl
509
- << " if((libssl = dlopen (LIBSSL_SO, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND )) == NULL) {" << std::endl
510
- << " fprintf(stderr, \" dlopen(%s) : %s\\ n\" , LIBSSL_SO, dlerror());" << std::endl
510
+ << " if((libssl = ossl_dlopen (LIBSSL_SO)) == NULL) {" << std::endl
511
+ << " fprintf(stderr, \" dlopen(%s) failed after searching multiple paths : %s\\ n\" , LIBSSL_SO, dlerror());" << std::endl
511
512
<< " exit(ELIBACC);" << std::endl
512
513
<< " }" << std::endl
513
514
<< std::endl
@@ -713,7 +714,7 @@ int main(int argc, const char **argv) {
713
714
globflags |= GLOB_APPEND;
714
715
}
715
716
for (auto i = 0 ; i < globbuf.gl_pathc ; i++) {
716
- auto p = std::filesystem::proximate (globbuf.gl_pathv [i], srcpath);
717
+ auto p = std::filesystem::path (globbuf.gl_pathv [i]). lexically_relative ( srcpath);
717
718
opt::headers[p] = true ;
718
719
}
719
720
globfree (&globbuf);
@@ -727,7 +728,7 @@ int main(int argc, const char **argv) {
727
728
globflags |= GLOB_APPEND;
728
729
}
729
730
for (auto i = 0 ; i < globbuf.gl_pathc ; i++) {
730
- auto p = std::filesystem::proximate (globbuf.gl_pathv [i], srcpath);
731
+ auto p = std::filesystem::path (globbuf.gl_pathv [i]). lexically_relative ( srcpath);
731
732
opt::headers[p] = false ;
732
733
}
733
734
globfree (&globbuf);
@@ -758,6 +759,8 @@ int main(int argc, const char **argv) {
758
759
std::filesystem::remove (dsthdr);
759
760
}
760
761
std::filesystem::copy_file (srcpath / hdr, dsthdr);
762
+ std::filesystem::permissions (dsthdr, std::filesystem::perms::owner_write |
763
+ std::filesystem::perms::owner_read);
761
764
}
762
765
}
763
766
0 commit comments