Skip to content

Commit c26f6de

Browse files
committed
linuxkm/linuxkm_wc_port.h: use more flexible logic to define WC_LKM_INDIRECT_SYM(), allowing various overrides and orthogonalizing the definitions proper, and add explanatory comments.
1 parent 0495f2c commit c26f6de

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

linuxkm/linuxkm_wc_port.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,32 @@
869869
extern const struct wolfssl_linuxkm_pie_redirect_table *wolfssl_linuxkm_get_pie_redirect_table(void);
870870
extern struct wolfssl_linuxkm_pie_redirect_table wolfssl_linuxkm_pie_redirect_table;
871871

872-
#if defined(CONFIG_X86)
873-
#define WC_LKM_INDIRECT_SYM(x) (wolfssl_linuxkm_pie_redirect_table.x)
872+
873+
#if defined(WC_LKM_INDIRECT_SYM)
874+
/* keep user-supplied override definition. */
875+
#elif defined(WC_LKM_INDIRECT_SYM_BY_FUNC_ONLY) || \
876+
defined(WC_LKM_INDIRECT_SYM_BY_DIRECT_TABLE_READ)
877+
/* keep user-supplied override method. */
878+
#elif defined(CONFIG_X86)
879+
#define WC_LKM_INDIRECT_SYM_BY_DIRECT_TABLE_READ
874880
#elif defined(CONFIG_ARM64)
875-
#define WC_LKM_INDIRECT_SYM(x) (wolfssl_linuxkm_get_pie_redirect_table()->x)
881+
/* direct access to wolfssl_linuxkm_pie_redirect_table.x on aarch64
882+
* produces GOT relocations, e.g. R_AARCH64_LD64_GOT_LO12_NC.
883+
*/
884+
#define WC_LKM_INDIRECT_SYM_BY_FUNC_ONLY
876885
#else
886+
/* for other archs, by default use the safe way. */
887+
#define WC_LKM_INDIRECT_SYM_BY_FUNC_ONLY
888+
#endif
889+
890+
#if defined(WC_LKM_INDIRECT_SYM)
891+
/* keep user-supplied override definition. */
892+
#elif defined(WC_LKM_INDIRECT_SYM_BY_FUNC_ONLY)
877893
#define WC_LKM_INDIRECT_SYM(x) (wolfssl_linuxkm_get_pie_redirect_table()->x)
894+
#elif defined(WC_LKM_INDIRECT_SYM_BY_DIRECT_TABLE_READ)
895+
#define WC_LKM_INDIRECT_SYM(x) (wolfssl_linuxkm_pie_redirect_table.x)
896+
#else
897+
#error no WC_LKM_INDIRECT_SYM method defined.
878898
#endif
879899

880900
#ifdef __PIE__

0 commit comments

Comments
 (0)