[PATCH] D55800: [ELF] Place .note in the first page to ensure they are available in core files

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 19 13:10:45 PST 2018


On Wed, Dec 19, 2018 at 12:16 PM Fāng-ruì Sòng <maskray at google.com> wrote:

>
> On 2018-12-19, Joerg Sonnenberger wrote:
> >On Wed, Dec 19, 2018 at 09:48:06AM -0800, Fāng-ruì Sòng via llvm-commits
> wrote:
> >> Can you give an example of writable SHT_NOTE section?
> >
> >You can create it in assembler by hand? I'm not sure if there are
> >documented case of (intentionally) writable SHT_NOTE sections>
> >Joerg
>
> % cat n.s
> .section .note.a, "aw", @note
> .quad 0
>
> .text
> nop
>
> .data
> .quad 0
>
> % as n.s -o n.o
> n.s: Assembler messages:
> n.s:1: Warning: setting incorrect section attributes for .note.a
>
> The warning suggests this may not be a reasonable construct. After this
> revision, lld does something similar to ld.bfd (there are two RW PT_LOAD
> segments, which is only one in gold) The output is still valid.
> Considering the construct itself (writable SHT_NOTE) may be
> questionable, I don't think we have to complicate the code a bit to
> handle the case.
>

I agree with Fang-rui. I cannot immediately come up with a valid use case
of writable .note sections. You can indeed create a writable .note section
by hand, but you can probably create a writable .interp section by creating
an writable .interp section by hand, so that's I think OK.


> % ld.bfd n.o -o n; readelf -WS n
> ld.bfd: warning: cannot find entry symbol _start; defaulting to
> 00000000004000b8
> There are 7 section headers, starting at offset 0x200200:
>
> Section Headers:
>   [Nr] Name              Type            Address          Off    Size   ES
> Flg Lk Inf Al
>   [ 0]                   NULL            0000000000000000 000000 000000
> 00      0   0  0
>   [ 1] .note.a           NOTE            00000000004000b0 0000b0 000008
> 00  WA  0   0  1
>   [ 2] .text             PROGBITS        00000000004000b8 0000b8 000001
> 00  AX  0   0  4
>   [ 3] .data             PROGBITS        00000000006000b9 2000b9 000008
> 00  WA  0   0  1
>   [ 4] .symtab           SYMTAB          0000000000000000 2000c8 0000d8
> 18      5   5  8
>   [ 5] .strtab           STRTAB          0000000000000000 2001a0 00002f
> 00      0   0  1
>   [ 6] .shstrtab         STRTAB          0000000000000000 2001cf 00002f
> 00      0   0  1
>
> % gold n.o -o n; readelf -WS n
> There are 8 section headers, starting at offset 0x1d8:
>
> Section Headers:
>   [Nr] Name              Type            Address          Off    Size   ES
> Flg Lk Inf Al
>   [ 0]                   NULL            0000000000000000 000000 000000
> 00      0   0  0
>   [ 1] .text             PROGBITS        00000000004000e8 0000e8 000001
> 00  AX  0   0  4
>   [ 2] .data             PROGBITS        00000000004010e9 0000e9 000008
> 00  WA  0   0  1
>   [ 3] .note.a           NOTE            00000000004010f1 0000f1 000008
> 00  WA  0   0  1
>   [ 4] .note.gnu.gold-version NOTE            0000000000000000 0000fc
> 00001c 00      0   0  4
>   [ 5] .symtab           SYMTAB          0000000000000000 000118 000060
> 18      6   1  8
>   [ 6] .strtab           STRTAB          0000000000000000 000178 000019
> 00      0   0  1
>   [ 7] .shstrtab         STRTAB          0000000000000000 000191 000046
> 00      0   0  1
>
> % ld.lld n.o -o n; readelf -WS n
> ld.lld: warning: cannot find entry symbol _start; defaulting to 0x202000
> There are 8 section headers, starting at offset 0x3088:
>
> Section Headers:
>   [Nr] Name              Type            Address          Off    Size   ES
> Flg Lk Inf Al
>   [ 0]                   NULL            0000000000000000 000000 000000
> 00      0   0  0
>   [ 1] .note.a           NOTE            0000000000201000 001000 000008
> 00  WA  0   0  1
>   [ 2] .text             PROGBITS        0000000000202000 002000 000001
> 00  AX  0   0  4
>   [ 3] .data             PROGBITS        0000000000203000 003000 000008
> 00  WA  0   0  1
>   [ 4] .comment          PROGBITS        0000000000000000 003008 000021
> 01  MS  0   0  1
>   [ 5] .symtab           SYMTAB          0000000000000000 003030 000018
> 18      7   1  8
>   [ 6] .shstrtab         STRTAB          0000000000000000 003048 000038
> 00      0   0  1
>   [ 7] .strtab           STRTAB          0000000000000000 003080 000001
> 00      0   0  1
>
> > but the gold comment you quotet earlier certainly considered it.
>
> The binutils-gdb commit 22f0da72ea2fc99e409548ce883b751aa822c2c3 added
> the code (ORDER_RO_NOTE), but I cannot find explanation for this choice.
>
>
> --
> 宋方睿
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181219/c59aa136/attachment-0001.html>


More information about the llvm-commits mailing list