2
votes

I know the .rodata section stores constant data in an ELF file. However, when I dump an ELF of a kernel module, I notice that there are two extra sections named rodata.str1.8 and rodata.str1.1. It seems that these two sections store constant variables and strings as well. But what exactly are the differences between these three rodata?

1

1 Answers

1
votes

It looks like .rodata.str1.1 has strings without alignment requirements, while .rodata.str1.8 must be 8-byte aligned. If you look at an ELF file with readelf this is visible:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00000000 000034 000050 00  AX  0   0  4
  [ 2] .rela.text        RELA            00000000 000184 000030 0c   I  8   1  4
  [ 3] .data             PROGBITS        00000000 000084 000000 00  WA  0   0  1
  [ 4] .bss              NOBITS          00000000 000084 000000 00  WA  0   0  1
  [ 5] .rodata.str1.8    PROGBITS        00000000 000088 000010 01 AMS  0   0  8   <---
  [ 6] .comment          PROGBITS        00000000 000098 000019 01  MS  0   0  1
  [ 7] .shstrtab         STRTAB          00000000 0001b4 000049 00      0   0  1
  [ 8] .symtab           SYMTAB          00000000 0000b4 0000a0 10      9   7  4
  [ 9] .strtab           STRTAB          00000000 000154 00002f 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)