The following assembly code: ``` .text .balign 256 func1: la.global $a0,exit nop nop nop .balign 256 func2: la.global $a0,exit nop nop nop ``` Surely we expect func1 @ 0x0 and func2 @ 0x100, however when assembled with no extra options with GAS 2.41, func1 is @ 0xfc and func2 0x20c. Add `-mno-relax` option to GAS could workaround this. This leads to miscompilation of https://github.com/NVIDIA/libglvnd/blob/master/src/GLdispatch/vnd-glapi/entry_loongarch64_tsd.c (which emits thousands of function thunks .baligned to 256B, and referenced by the index at runtime), and leads to broken GL and thus broken desktop.
Sorry for disturbance here, the misaligned symbols in the .o file is expected; however ld is expected to re-align it, which failed in the case of libglvnd.
The new code used to reproduce the ld issue is here: ``` .text .balign 256 func1: la.global $a0,exit nop .word 0x12345678 .word 0x0 .balign 256 func2: la.global $a0,exit nop .word 0x12345678 .word 0x0 ``` Build it with: (assume it's saved as test.s) ``` # as test.s -o test.o # ld test.o -shared ``` On my setup with binutils 2.41 native, I got func1 @ 0x2fc and func2 @ 0x40c, both are not properly aligned.
It should be fixed with 2.42.