Skip to content

Commit 0bce126

Browse files
t-8chtsbogend
authored andcommitted
MIPS: Implement ARCH_HAS_CC_CAN_LINK
The generic CC_CAN_LINK detection does not handle different byte orders or ABIs. This may lead to userprogs which are not actually runnable on the target kernel. Use architecture-specific logic supporting byte orders instead. Modern 64-bit toolchains default to a n32 libc, which are not supported by all kernel configurations, as MIPS32_N32 is optional. On 64-bit, test for a n32 ABI libc first and fall back to o64 and o32 if necessary. Link: https://lore.kernel.org/lkml/20260105100507-14db55e3-aa71-48bf-a6ac-33b186bd082f@linutronix.de/ Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent e93bb4b commit 0bce126

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

arch/mips/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config MIPS
44
default y
55
select ARCH_32BIT_OFF_T if !64BIT
66
select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
7+
select ARCH_HAS_CC_CAN_LINK
78
select ARCH_HAS_CPU_CACHE_ALIASING
89
select ARCH_HAS_CPU_FINALIZE_INIT
910
select ARCH_HAS_CURRENT_STACK_POINTER
@@ -3125,6 +3126,33 @@ config CC_HAS_MNO_BRANCH_LIKELY
31253126
config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
31263127
def_bool y if CC_IS_CLANG
31273128

3129+
config ARCH_CC_CAN_LINK_N32
3130+
bool
3131+
default $(cc_can_link_user,-mabi=n32 -EL) if MIPS32_N32 && CPU_LITTLE_ENDIAN
3132+
default $(cc_can_link_user,-mabi=n32 -EB) if MIPS32_N32 && CPU_BIG_ENDIAN
3133+
3134+
config ARCH_CC_CAN_LINK_N64
3135+
bool
3136+
default $(cc_can_link_user,-mabi=64 -EL) if 64BIT && CPU_LITTLE_ENDIAN
3137+
default $(cc_can_link_user,-mabi=64 -EB) if 64BIT && CPU_BIG_ENDIAN
3138+
3139+
config ARCH_CC_CAN_LINK_O32
3140+
bool
3141+
default $(cc_can_link_user,-mabi=32 -EL) if (32BIT || MIPS32_O32) && CPU_LITTLE_ENDIAN
3142+
default $(cc_can_link_user,-mabi=32 -EB) if (32BIT || MIPS32_O32) && CPU_BIG_ENDIAN
3143+
3144+
config ARCH_CC_CAN_LINK
3145+
def_bool ARCH_CC_CAN_LINK_N32 || ARCH_CC_CAN_LINK_N64 || ARCH_CC_CAN_LINK_O32
3146+
3147+
config ARCH_USERFLAGS
3148+
string
3149+
default "-mabi=n32 -EL" if ARCH_CC_CAN_LINK_N32 && CPU_LITTLE_ENDIAN
3150+
default "-mabi=n32 -EB" if ARCH_CC_CAN_LINK_N32 && CPU_BIG_ENDIAN
3151+
default "-mabi=64 -EL" if ARCH_CC_CAN_LINK_N64 && CPU_LITTLE_ENDIAN
3152+
default "-mabi=64 -EB" if ARCH_CC_CAN_LINK_N64 && CPU_BIG_ENDIAN
3153+
default "-mabi=32 -EL" if ARCH_CC_CAN_LINK_O32 && CPU_LITTLE_ENDIAN
3154+
default "-mabi=32 -EB" if ARCH_CC_CAN_LINK_O32 && CPU_BIG_ENDIAN
3155+
31283156
menu "Power management options"
31293157

31303158
config ARCH_HIBERNATION_POSSIBLE

0 commit comments

Comments
 (0)