*.so built on target machine is not recognized if using glibc-2.24

Hi, it's my first topic in this forum, just shared with you a problem I came across when building programs on target machine(not cross build).

I just built a lede image for Malta( for Qemu/mipsel) with gcc-5.4 and glibc-2.24 rather than musl-1.16 and tried to build a simple shared library on target machine ( mt7628 ) like this:

root@mt7628 # cat tso.c
#include <stdio.h>
int sum(int a,int b){
fprintf(stderr,"sum called\n");
return a+b;

root@mt7628 # cat main.c

extern int sum(int a,int b);
int main(){
return 0;

root@mt7628 # gcc -fPIC -shared -o tso.so tso.c
root@mt7628 # gcc -o test main.c tso.so -Wl,-rpath=/root

The build is successful and the target share library looks generated fine. However, if I try to load this so file, it's not recognized, for example:

root@mt7628 #./test
./test: error while loading shared libraries: /root/tso.so: ELF file ABI version invalid

root@mt7628 # ldd tso.so
$ not a dynamic executable
root@mt7628 # ldd test
$ not a dynamic executable

I spent few hours to find out why the library loader does not work and found the reason is at the header ABI Version number:

root@mt7628:~# readelf -a test |head -n 10
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 05 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 5
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1

if I change the 8th byte in elf header to 00 in both test and tso.so, then the issue is gone. test.so can be loaded and the main prog can also run as expected.

I built another image using musl-1.16, and noticed gcc generated the same 05 in elf header. but such issue does not happen - everything just works.

I don't know what is the difference between musl and glibc and why with glibc the ldd can not work on target machine. Anyway, thanks lede for so many choices, there is still a way for me to locally build n run progs.