Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Nov 2020 15:27:31 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Paul Floyd <pjfloyd@wanadoo.fr>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: FreeBSD 12.2 extra RW program header
Message-ID:  <X7J%2BQ8ngg8Fjxn54@kib.kiev.ua>
In-Reply-To: <8ff8067a-3354-3587-4eda-1aa802f6c86b@wanadoo.fr>
References:  <8ff8067a-3354-3587-4eda-1aa802f6c86b@wanadoo.fr>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 16, 2020 at 02:07:32PM +0100, Paul Floyd wrote:
> Hi
> 
> 
> I see that FreeBSD 12.2 has added an extra RW program header.
> 
> Can anyone explain what this does? (My initial guess is things like thread
> mutexes and barriers).
> 
> Full details:
That's not full details, you stripped readelf output that describes it.

The first rw data segment is really ro after linking is finished, you can
see that RELRO segment location is identical to the first loadable rw segment.
It contains the following sections typically
	.ctors .dtors .dynamic .got
.got (but not .got.plt) is patched by rtld during load.

I do not remember when did we enabled relro.  Most likely long time before 12.1,
and the new segment is due to the way relro handling changed in lld 10.

> 
> 
> 12.1
> 
> Program Headers:
>   Type           Offset             VirtAddr           PhysAddr
>                  FileSiz            MemSiz              Flg Align
>   PHDR           0x0000000000000040 0x0000000000200040 0x0000000000200040
>                  0x0000000000000230 0x0000000000000230  R      0x8
>   INTERP         0x0000000000000270 0x0000000000200270 0x0000000000200270
>                  0x0000000000000015 0x0000000000000015  R      0x1
>       [Requesting program interpreter: /libexec/ld-elf.so.1]
>   LOAD           0x0000000000000000 0x0000000000200000 0x0000000000200000
>                  0x000000000000086c 0x000000000000086c  R 0x1000
>   LOAD           0x0000000000001000 0x0000000000201000 0x0000000000201000
>                  0x00000000000006b0 0x00000000000006b0  R E 0x1000
>   LOAD           0x0000000000002000 0x0000000000202000 0x0000000000202000
>                  0x0000000000001158 0x0000000000002014  RW 0x1000
>   DYNAMIC        0x0000000000003028 0x0000000000203028 0x0000000000203028
>                  0x0000000000000130 0x0000000000000130  RW     0x8
> 
> 12.2:
> 
> Program Headers:
>   Type           Offset             VirtAddr           PhysAddr
>                  FileSiz            MemSiz              Flg Align
>   PHDR           0x0000000000000040 0x0000000000200040 0x0000000000200040
>                  0x0000000000000268 0x0000000000000268  R      0x8
>   INTERP         0x00000000000002a8 0x00000000002002a8 0x00000000002002a8
>                  0x0000000000000015 0x0000000000000015  R      0x1
>       [Requesting program interpreter: /libexec/ld-elf.so.1]
>   LOAD           0x0000000000000000 0x0000000000200000 0x0000000000200000
>                  0x00000000000008bc 0x00000000000008bc  R 0x1000
>   LOAD           0x00000000000008c0 0x00000000002018c0 0x00000000002018c0
>                  0x00000000000006c0 0x00000000000006c0  R E 0x1000
>   LOAD           0x0000000000000f80 0x0000000000202f80 0x0000000000202f80
>                  0x0000000000000158 0x0000000000000158  RW 0x1000
> 
> 
> extra header here ->
> 
>   LOAD           0x00000000000010d8 0x00000000002040d8 0x00000000002040d8
>                  0x0000000000000090 0x00000000000000a8  RW 0x1000
> 
>   DYNAMIC        0x0000000000000fa8 0x0000000000202fa8 0x0000000000202fa8
>                  0x0000000000000130 0x0000000000000130  RW     0x8
> 
> 
> A+
> 
> Paul
> 
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?X7J%2BQ8ngg8Fjxn54>