attribute used for o3 and lto

This commit is contained in:
2024-03-30 22:20:36 +01:00
parent 051523a77e
commit b233a92f0f
2 changed files with 16 additions and 16 deletions

View File

@@ -15,9 +15,9 @@
#define STACK_CHK_GUARD 0x2e61e13e4d5ae23c
#endif
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
__attribute__((used)) uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
extern "C" __attribute__((noreturn)) void __stack_chk_fail(void) {
extern "C" __attribute__((noreturn, used)) void __stack_chk_fail(void) {
assert2(false, "Stack protection triggered!");
}
@@ -105,8 +105,8 @@ struct type_mismatch_info {
#define SAN_STOP true
#define is_aligned(value, alignment) !(value & (alignment - 1))
[[maybe_unused]] void __ubsan_handle_type_mismatch_v1(struct type_mismatch_info *type_mismatch,
uintptr_t pointer) {
__attribute__((used)) void __ubsan_handle_type_mismatch_v1(struct type_mismatch_info *type_mismatch,
uintptr_t pointer) {
struct source_location *location = &type_mismatch->location;
if (pointer == 0) {
writestr_no_yield("Warning: null pointer access \n");
@@ -122,47 +122,47 @@ struct type_mismatch_info {
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_pointer_overflow() {
__attribute__((used)) void __ubsan_handle_pointer_overflow() {
writestr_no_yield("Warning: pointer overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_load_invalid_value() {
__attribute__((used)) void __ubsan_handle_load_invalid_value() {
writestr_no_yield("Warning: invalid value load\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_out_of_bounds() {
__attribute__((used)) void __ubsan_handle_out_of_bounds() {
writestr_no_yield("Warning: out of bounds\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_add_overflow() {
__attribute__((used)) void __ubsan_handle_add_overflow() {
writestr_no_yield("Warning: add overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_missing_return() {
__attribute__((used)) void __ubsan_handle_missing_return() {
writestr_no_yield("Warning: missing return\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_sub_overflow() {
__attribute__((used)) void __ubsan_handle_sub_overflow() {
writestr_no_yield("Warning: sub overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_shift_out_of_bounds() {
__attribute__((used)) void __ubsan_handle_shift_out_of_bounds() {
writestr_no_yield("Warning: shift overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_builtin_unreachable() {
__attribute__((used)) void __ubsan_handle_builtin_unreachable() {
writestr_no_yield("Warning: unreachable\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_mul_overflow() {
__attribute__((used)) void __ubsan_handle_mul_overflow() {
writestr_no_yield("Warning: multiplication overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_divrem_overflow() {
__attribute__((used)) void __ubsan_handle_divrem_overflow() {
writestr_no_yield("Warning: division overflow\n");
if (SAN_STOP) _hcf();
}
[[maybe_unused]] void __ubsan_handle_nonnull_arg() {
__attribute__((used)) void __ubsan_handle_nonnull_arg() {
writestr_no_yield("Warning: null argument\n");
if (SAN_STOP) _hcf();
}

View File

@@ -6,7 +6,7 @@
#include <stdint.h>
// GCC Bug? even with freestanding and no-builtin gcc tries calling that
void *memset(void *s, int c, size_t n) {
__attribute__((used)) void *memset(void *s, int c, size_t n) {
uint8_t *p = (uint8_t *) s;
for (size_t i = 0; i < n; i++) {