Skip to content

Commit

Permalink
libpal: fix builds using libpal
Browse files Browse the repository at this point in the history
Add missing #include <string.h> since memset is needed by code generated
for the libpal access mechansim. Also, fix C builds by guarding the
extern "C" with #ifdef __cplusplus. Finally, make sure libpal.h is
public and can be included by dependents.

Signed-off-by: Nick Rosbrook <[email protected]>
  • Loading branch information
Nick Rosbrook authored and JaredWright committed Jul 10, 2020
1 parent f27eea4 commit bea1fab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions libpal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")

add_library(libpal cpuid_x64.asm)
set_target_properties(libpal PROPERTIES OUTPUT_NAME pal)
target_include_directories(libpal PUBLIC ${CMAKE_CURRENT_LIST_DIR})
endif()
5 changes: 4 additions & 1 deletion libpal/libpal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ typedef struct pal_cpuid_register_values {
uint32_t edx;
} pal_cpuid_register_values;

extern "C" pal_cpuid_register_values pal_execute_cpuid(uint32_t eax, uint32_t ecx);
#ifdef __cplusplus
extern "C"
#endif
pal_cpuid_register_values pal_execute_cpuid(uint32_t eax, uint32_t ecx);

#endif
3 changes: 2 additions & 1 deletion pal/generator/c_header_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def generate(self, regs, outpath):

if config.access_mechanism == "libpal":
self.gadgets["pal.header_depends"].includes.extend([
"<libpal.h>"
"<libpal.h>",
"<string.h>", # for memset
])

outfile_path = os.path.join(outpath, reg.name.lower() + ".h")
Expand Down
3 changes: 2 additions & 1 deletion pal/generator/cxx_header_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def generate(self, regs, outpath):

if config.access_mechanism == "libpal":
self.gadgets["pal.header_depends"].includes.extend([
"<libpal.h>"
"<libpal.h>",
"<string.h>", # for memset
])

outfile_path = os.path.join(outpath, reg.name.lower() + ".h")
Expand Down

0 comments on commit bea1fab

Please sign in to comment.