$ cat a.s .file "a.c" .type a,@object .section .rodata.str1.1,"aMS",@progbits,1 .globl a a: .size a, 5 # note that size is 5! .align 8 .byte 0x61 .byte 0x62 .zero 1 .type b,@object .globl b b: .size b, 2 .byte 0x62 .zero 1 .section .note.GNU-stack,"",@progbits $ as -o a.o a.s $ ld -shared -o a.so a.o $ readelf -a a.o (...) 7: 00000000 5 OBJECT GLOBAL DEFAULT 4 a 8: 00000003 2 OBJECT GLOBAL DEFAULT 4 b (note that 'a' has size 5) $ objdump -s a.so Contents of section .rodata: 0160 61620000 00000000 ab...... As you can see, the value for the symbol 'a' is broken. It should be 'ab\0b\0'.
The contents of "MS" sections must be zero-terminated strings.
(In reply to comment #1) > The contents of "MS" sections must be zero-terminated strings. which they are: a = 'ab\0b\0' b = 'b\0'
> a = 'ab\0b\0' This is not a valid zero-terminated string.