Skip to content

build: add -Wa,-mbranches-within-32B-boundaries compiler flag #5267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE

# Assembler Options
-Wa,--noexecstack
${BRANCH_ALIGN_FLAG}

# Suppressed Warnings
-Wno-deprecated-declarations
Expand Down Expand Up @@ -373,6 +374,12 @@ if (NOT S2N_EXECINFO_AVAILABLE)
endif()
feature_probe_result(S2N_STACKTRACE ${S2N_STACKTRACE})

if (SN_BRANCH_ALIGN AND NOT S2N_FUZZ_TEST)
set (BRANCH_ALIGN_FLAG "-Wa,-mbranches-within-32B-boundaries")
else()
set (BRANCH_ALIGN_FLAG "")
endif()

if (S2N_INTERN_LIBCRYPTO)

# Check if the AWS::crypto target has beeen added and handle it
Expand Down
19 changes: 19 additions & 0 deletions tests/features/S2N_BRANCH_ALIGN.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

int main() {
return 0;
}

1 change: 1 addition & 0 deletions tests/features/S2N_BRANCH_ALIGN.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Wa,-mbranches-within-32B-boundaries
Loading