Skip to content

Commit aba9ee4

Browse files
authored
Merge pull request #9319 from douzzer/20251018-linuxkm-gdwarf-4-g1
20251018-linuxkm-gdwarf-4-g1
2 parents c091c8b + 9881c95 commit aba9ee4

5 files changed

Lines changed: 44 additions & 34 deletions

File tree

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,14 @@ then
740740
# "Unsupported DW_TAG_atomic_type(0x47): type: 0x1eefc" in some
741741
# kernel module builds.
742742
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -DWC_SIPHASH_NO_ASM -gdwarf-4"
743+
AS_IF([test "$ax_enable_debug" = "yes"],
744+
[AM_CFLAGS="$AM_CFLAGS -g3"],
745+
[AM_CFLAGS="$AM_CFLAGS -g1"])
746+
AM_CCASFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -DWC_SIPHASH_NO_ASM -gdwarf-4"
747+
AS_IF([test "$ax_enable_debug" = "yes"],
748+
[AM_CCASFLAGS="$AM_CFLAGS -g3"],
749+
[AM_CCASFLAGS="$AM_CFLAGS -g1"])
750+
743751
ENABLED_NO_LIBRARY=yes
744752
ENABLED_BENCHMARK=no
745753
output_objdir="$(realpath "$output_objdir")/linuxkm"

linuxkm/Kbuild

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,16 @@ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
214214
echo 'OK.'; \
215215
fi; \
216216
cd "$(obj)" || exit $$?; \
217-
for file in $(WOLFCRYPT_PIE_FILES); do \
218-
$(OBJCOPY) --rename-section .text=.text.wolfcrypt \
219-
--rename-section .text.unlikely=.text.wolfcrypt \
220-
--rename-section .rodata=.rodata.wolfcrypt \
221-
--rename-section .rodata.str1.1=.rodata.wolfcrypt \
222-
--rename-section .rodata.str1.8=.rodata.wolfcrypt \
223-
--rename-section .rodata.cst16=.rodata.wolfcrypt \
224-
--rename-section .rodata.cst32=.rodata.wolfcrypt \
225-
--rename-section .data=.data.wolfcrypt \
226-
--rename-section .data.rel.local=.data.wolfcrypt \
227-
--rename-section .bss=.bss.wolfcrypt "$$file" || exit $$?; \
228-
done; \
229-
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
217+
for file in $(WOLFCRYPT_PIE_FILES); do \
218+
$(OBJCOPY) $$($(READELF) --sections --wide "$$file" | \
219+
$(AWK) ' \
220+
{ \
221+
if (match($$0, "^ *\\[ *[0-9]+\\] +\\.(text|rodata|data|bss)(\\.[^ ]+)? ", a)) { \
222+
printf("--rename-section .%s%s=.%s_wolfcrypt ", a[1], a[2], a[1]); \
223+
} \
224+
}') "$$file" || exit $$?; \
225+
done; \
226+
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
230227
{ $(READELF) --sections --syms --wide $(WOLFCRYPT_PIE_FILES) | \
231228
$(AWK) -v obj="$(obj)" ' \
232229
/^File:/ { \
@@ -253,12 +250,12 @@ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
253250
if (phase == 1) { \
254251
if (match($$0, "^ *\\[ *([0-9]+)\\] +([^ ]+) ", a)) {\
255252
switch (a[2]) { \
256-
case ".text.wolfcrypt": \
253+
case ".text_wolfcrypt": \
257254
{ \
258255
wolfcrypt_text_sections[a[1]] = a[2]; \
259256
next; \
260257
} \
261-
case /^\.(data|rodata|bss)\.wolfcrypt$$/: \
258+
case /^\.(data|rodata|bss)_wolfcrypt$$/: \
262259
{ \
263260
wolfcrypt_data_sections[a[1]] = a[2]; \
264261
next; \
@@ -301,7 +298,7 @@ RENAME_PIE_TEXT_AND_DATA_SECTIONS := \
301298
}}'; } || \
302299
{ echo 'Error: symbol(s) missed by containerization.' >&2; exit 1; }; \
303300
if [[ "$(quiet)" != "silent_" ]]; then \
304-
echo ' wolfCrypt .{text,data,rodata} sections containerized to .{text,data,rodata}.wolfcrypt'; \
301+
echo ' wolfCrypt .{text,data,rodata,bss} sections containerized to .{text,data,rodata}_wolfcrypt'; \
305302
fi
306303
endif
307304

linuxkm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ GENERATE_RELOC_TAB := $(READELF) --wide -r libwolfssl.ko | \
107107
printf("%s\n ", \
108108
"const unsigned int wc_linuxkm_pie_reloc_tab[] = { "); \
109109
} \
110-
/^Relocation section '\''\.rela\.text\.wolfcrypt'\''/ { \
110+
/^Relocation section '\''\.rela\.text_wolfcrypt'\''/ { \
111111
p=1; \
112112
next; \
113113
} \
@@ -171,7 +171,7 @@ module-update-fips-hash: libwolfssl.ko
171171
@if test -z '$(FIPS_HASH)'; then echo ' $$FIPS_HASH is unset' >&2; exit 1; fi
172172
@if [[ ! '$(FIPS_HASH)' =~ [0-9a-fA-F]{64} ]]; then echo ' $$FIPS_HASH is malformed' >&2; exit 1; fi
173173
@readarray -t rodata_segment < <($(READELF) --wide --sections libwolfssl.ko | \
174-
sed -E -n 's/^[[:space:]]*\[[[:space:]]*([0-9]+)\][[:space:]]+\.rodata\.wolfcrypt[[:space:]]+PROGBITS[[:space:]]+[0-9a-fA-F]+[[:space:]]+([0-9a-fA-F]+)[[:space:]].*$$/\1\n\2/p'); \
174+
sed -E -n 's/^[[:space:]]*\[[[:space:]]*([0-9]+)\][[:space:]]+\.rodata_wolfcrypt[[:space:]]+PROGBITS[[:space:]]+[0-9a-fA-F]+[[:space:]]+([0-9a-fA-F]+)[[:space:]].*$$/\1\n\2/p'); \
175175
if [[ $${#rodata_segment[@]} != 2 ]]; then echo ' unexpected rodata_segment.' >&2; exit 1; fi; \
176176
readarray -t verifyCore_attrs < <($(READELF) --wide --symbols libwolfssl.ko | \
177177
sed -E -n 's/^[[:space:]]*[0-9]+: ([0-9a-fA-F]+)[[:space:]]+([0-9]+)[[:space:]]+OBJECT[[:space:]]+[A-Z]+[[:space:]]+[A-Z]+[[:space:]]+'"$${rodata_segment[0]}"'[[:space:]]+verifyCore$$/\1\n\2/p'); \

linuxkm/wolfcrypt.lds

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
SECTIONS {
22
. = ALIGN(4096);
3-
.text.wolfcrypt : {
3+
.text_wolfcrypt : {
44
__wc_text_start = .;
5-
*(.text.wolfcrypt)
5+
*(.text_wolfcrypt)
66
. = ALIGN(4096);
77
__wc_text_end = .;
88
}
99
. = ALIGN(4096);
10-
.rodata.wolfcrypt : {
10+
.rodata_wolfcrypt : {
1111
__wc_rodata_start = .;
12-
*(.rodata.wolfcrypt)
12+
*(.rodata_wolfcrypt)
1313
. = ALIGN(4096);
1414
__wc_rodata_end = .;
1515
}
1616
. = ALIGN(4096);
17-
.data.wolfcrypt : {
17+
.data_wolfcrypt : {
1818
__wc_rwdata_start = .;
19-
*(.data.wolfcrypt)
19+
*(.data_wolfcrypt)
2020
. = ALIGN(4096);
2121
__wc_rwdata_end = .;
2222
}
2323
. = ALIGN(4096);
24-
.bss.wolfcrypt : {
24+
.bss_wolfcrypt : {
2525
__wc_bss_start = .;
26-
*(.bss.wolfcrypt)
26+
*(.bss_wolfcrypt)
2727
. = ALIGN(4096);
2828
__wc_bss_end = .;
2929
}

wolfcrypt/test/test.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t tls12_kdf_test(void);
621621
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prf_test(void);
622622
#endif
623623
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sshkdf_test(void);
624-
#ifdef WOLFSSL_TLS13
624+
#if defined(WOLFSSL_TLS13) && !defined(NO_HMAC)
625625
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t tls13_kdf_test(void);
626626
#endif
627627
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t x963kdf_test(void);
@@ -1944,14 +1944,14 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
19441944
#endif /* WOLFSSL_HAVE_PRF && HAVE_HKDF && !NO_HMAC && */
19451945
/* WOLFSSL_BASE16 && !WOLFSSL_NO_TLS12 */
19461946

1947-
#ifdef WOLFSSL_TLS13
1947+
#if defined(WOLFSSL_TLS13) && !defined(NO_HMAC)
19481948
PRIVATE_KEY_UNLOCK();
19491949
if ( (ret = tls13_kdf_test()) != 0)
19501950
TEST_FAIL("TLSv1.3 KDF test failed!\n", ret);
19511951
else
19521952
TEST_PASS("TLSv1.3 KDF test passed!\n");
19531953
PRIVATE_KEY_LOCK();
1954-
#endif /* WOLFSSL_TLS13 */
1954+
#endif /* WOLFSSL_TLS13 && !NO_HMAC */
19551955

19561956
#if defined(HAVE_X963_KDF) && defined(HAVE_ECC)
19571957
if ( (ret = x963kdf_test()) != 0)
@@ -20769,7 +20769,9 @@ static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
2076920769
}
2077020770
#endif
2077120771

20772-
#if defined(WC_RSA_PSS) && !defined(HAVE_FIPS_VERSION) /* not supported with FIPSv1 */
20772+
#if defined(WC_RSA_PSS) && \
20773+
(!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,0)) && \
20774+
!defined(WC_NO_RNG)
2077320775
/* Need to create known good signatures to test with this. */
2077420776
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \
2077520777
!defined(WOLF_CRYPTO_CB_ONLY_RSA)
@@ -21131,7 +21133,8 @@ static wc_test_ret_t rsa_pss_test(WC_RNG* rng, RsaKey* key)
2113121133
return ret;
2113221134
}
2113321135
#endif /* !WOLFSSL_RSA_VERIFY_ONLY && !WOLFSSL_RSA_PUBLIC_ONLY */
21134-
#endif
21136+
#endif /* WC_RSA_PSS && (!HAVE_FIPS || FIPS_VERSION_GE(5,0)) && !WC_NO_RNG */
21137+
2113521138

2113621139
#ifdef WC_RSA_NO_PADDING
2113721140
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_no_pad_test(void)
@@ -23176,7 +23179,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void)
2317623179
#endif /* WOLFSSL_CERT_REQ */
2317723180
#endif /* WOLFSSL_CERT_GEN */
2317823181

23179-
#if defined(WC_RSA_PSS) && !defined(HAVE_FIPS_VERSION) /* not supported with FIPSv1 */
23182+
#if defined(WC_RSA_PSS) && \
23183+
(!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,0)) && \
23184+
!defined(WC_NO_RNG)
2318023185
/* Need to create known good signatures to test with this. */
2318123186
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \
2318223187
!defined(WOLF_CRYPTO_CB_ONLY_RSA)
@@ -28431,7 +28436,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t tls12_kdf_test(void)
2843128436
#endif /* WOLFSSL_HAVE_PRF && HAVE_HKDF && !NO_HMAC && */
2843228437
/* WOLFSSL_BASE16 && !WOLFSSL_NO_TLS12 */
2843328438

28434-
#ifdef WOLFSSL_TLS13
28439+
#if defined(WOLFSSL_TLS13) && !defined(NO_HMAC)
2843528440

2843628441
#define TLSV13_PSK_DHE_SZ 40
2843728442
typedef struct {
@@ -29127,7 +29132,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t tls13_kdf_test(void)
2912729132
return ret;
2912829133
}
2912929134

29130-
#endif /* WOLFSSL_TLS13 */
29135+
#endif /* WOLFSSL_TLS13 && !NO_HMAC */
2913129136

2913229137
static const int fiducial2 = WC_TEST_RET_LN; /* source code reference point --
2913329138
* see print_fiducials() below.

0 commit comments

Comments
 (0)