mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-01 04:03:24 +03:00
bindexplib: Always export executable symbols, even they are also readable
Previously bindexplib discarded read-only non-function symbols even in executable/code sections, but in some specific cases they could still mark functions. An example is provided by nop.asm in the AuoExportDll test, which exports a function only marked by a label. This symbol can be used from C/C++ code, but without this change it would result in an unresolved external symbol when built as a DLL on Windows.
This commit is contained in:
1 parent
78104bd7bc
commit
85e08370d0
4 files changed
+24
-1
No files matched your search
@@ -308,7 +308,8 @@ public:
|
||||
this->DataSymbols.insert(symbol);
|
||||
} else {
|
||||
if ( pSymbolTable->Type ||
|
||||
!(SectChar & IMAGE_SCN_MEM_READ)) {
|
||||
!(SectChar & IMAGE_SCN_MEM_READ) ||
|
||||
(SectChar & IMAGE_SCN_MEM_EXECUTE)) {
|
||||
this->Symbols.insert(symbol);
|
||||
} else {
|
||||
// printf(" strange symbol: %s \n",symbol.c_str());
|
||||
|
||||
@@ -11,5 +11,11 @@ if(MSVC)
|
||||
set_target_properties(say PROPERTIES ENABLE_EXPORTS ON)
|
||||
add_library(autoexport_for_exec SHARED hello2.c)
|
||||
target_link_libraries(autoexport_for_exec say)
|
||||
if(NOT MSVC_VERSION VERSION_LESS 1600)
|
||||
enable_language(ASM_MASM)
|
||||
target_sources(autoexport PRIVATE nop.asm)
|
||||
set_property(SOURCE nop.asm PROPERTY COMPILE_FLAGS /safeseh)
|
||||
target_compile_definitions(say PRIVATE HAS_JUSTNOP)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(say autoexport autoexport2)
|
||||
@@ -0,0 +1,12 @@
|
||||
IFDEF RAX
|
||||
ELSE
|
||||
.MODEL FLAT,C
|
||||
ENDIF
|
||||
|
||||
SOME SEGMENT EXECUTE READ
|
||||
|
||||
public justnop
|
||||
justnop:
|
||||
ret
|
||||
|
||||
END
|
||||
@@ -12,6 +12,7 @@ int WINAPI foo();
|
||||
// test regular C
|
||||
int bar();
|
||||
int objlib();
|
||||
void justnop();
|
||||
}
|
||||
|
||||
// test c++ functions
|
||||
@@ -42,5 +43,8 @@ int main()
|
||||
bar();
|
||||
objlib();
|
||||
printf("\n");
|
||||
#ifdef HAS_JUSTNOP
|
||||
justnop();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user