Skip to content

Commit

Permalink
Fix AppleClang 15 FIPS Shared Build
Browse files Browse the repository at this point in the history
  • Loading branch information
skmcgrail committed Oct 5, 2023
1 parent b405bb9 commit 3036f4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crypto/fipsmodule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,12 @@ elseif(FIPS_SHARED)
# respective start and end markers.
add_custom_command(
OUTPUT fips_apple_start.o
COMMAND ${CMAKE_C_COMPILER} -arch ${CMAKE_SYSTEM_PROCESSOR} -isysroot ${CMAKE_OSX_SYSROOT} -c ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c -DAWSLC_FIPS_SHARED_START -o fips_apple_start.o
COMMAND ${CMAKE_C_COMPILER} -arch ${CMAKE_SYSTEM_PROCESSOR} -isysroot ${CMAKE_OSX_SYSROOT} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -c ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c -DAWSLC_FIPS_SHARED_START -o fips_apple_start.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c
)
add_custom_command(
OUTPUT fips_apple_end.o
COMMAND ${CMAKE_C_COMPILER} -arch ${CMAKE_SYSTEM_PROCESSOR} -isysroot ${CMAKE_OSX_SYSROOT} -c ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c -DAWSLC_FIPS_SHARED_END -o fips_apple_end.o
COMMAND ${CMAKE_C_COMPILER} -arch ${CMAKE_SYSTEM_PROCESSOR} -isysroot ${CMAKE_OSX_SYSROOT} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -c ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c -DAWSLC_FIPS_SHARED_END -o fips_apple_end.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared_library_marker.c
)

Expand Down
11 changes: 7 additions & 4 deletions util/fipstools/inject_hash/inject_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func doLinux(objectBytes []byte, isStatic bool) ([]byte, []byte, error) {
return moduleText, moduleROData, nil
}


func doAppleOS(objectBytes []byte) ([]byte, []byte, error) {

object, err := macho.NewFile(bytes.NewReader(objectBytes))
Expand Down Expand Up @@ -221,6 +220,13 @@ func doAppleOS(objectBytes []byte) ([]byte, []byte, error) {
return nil, nil, fmt.Errorf("symbol %q at %x, which is below base of %x\n", symbol.Name, symbol.Value, base)
}

// Skip debugging symbols
// "If any of these 3 bits are set, the symbol is a symbolic debugging table (stab) entry. In that case, the entire n_type field is interpreted as a stab value."
// https://web.archive.org/web/20090901205800/http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
if symbol.Type&0xe0 != 0 {
continue
}

value := symbol.Value - base
switch symbol.Name {
case "_BORINGSSL_bcm_text_start":
Expand Down Expand Up @@ -296,8 +302,6 @@ func doAppleOS(objectBytes []byte) ([]byte, []byte, error) {
return moduleText, moduleROData, nil
}



func do(outPath, oInput string, arInput string, appleOS bool) error {
var objectBytes []byte
var isStatic bool
Expand Down Expand Up @@ -365,7 +369,6 @@ func do(outPath, oInput string, arInput string, appleOS bool) error {
return err
}


var zeroKey [64]byte
mac := hmac.New(sha256.New, zeroKey[:])

Expand Down

0 comments on commit 3036f4f

Please sign in to comment.