This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Skip PT_DYNAMIC segment if its p_filesz == 0 [BZ #22101]
- From: Zack Weinberg <zackw at panix dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 25 Sep 2017 21:34:41 -0400
- Subject: Re: [PATCH] Skip PT_DYNAMIC segment if its p_filesz == 0 [BZ #22101]
- Authentication-results: sourceware.org; auth=none
- References: <20170926003314.GA18765@gmail.com> <CAKCAbMhF6M8VGs+nybEsjCEXKNwCxOteRc6Wac4sjQ1Zydtg9Q@mail.gmail.com> <CAMe9rOqUUdZDiztO_mo=10GOWJp4UqocrU9RFF4Xty6uVDkpyw@mail.gmail.com>
On Mon, Sep 25, 2017 at 9:12 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On 9/25/17, Zack Weinberg <zackw@panix.com> wrote:
>> On Mon, Sep 25, 2017 at 8:33 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> ELF object generated with "objcopy --only-keep-debug" has
>>>
>>> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
>>> DYNAMIC 0x0+e28 0x0+200e40 0x0+200e40 0x0+ 0x0+1a0 RW 0x8
>>>
>>> with 0 file size. ld.so should skip such PT_DYNAMIC segments.
>>
>> Why should ld.so skip such PT_DYNAMIC segments? It seems like loading
>> empty segments should be harmless, and ...
>
> Not all valid segments can have zero p_filesz. The valid PT_DYNAMIC segment
> should have non-zero p_filesz.
Argh, I misremembered what a PT_DYNAMIC segment is. I've checked the
gABI now and I see that it specifies that an empty PT_DYNAMIC segment
is in fact invalid in a shared object (since certain entries in the
array are mandatory) ... but the change still makes me nervous. What
_exactly_ does our ld.so do with this now, in the absence of your
change? If it does anything other than crash, I fear there may be
programs out there relying on the behavior.
(And I'd like you to specifically check that your change doesn't break
GDB's ability to load debug-only objects, even though I'm pretty sure
it doesn't use dlopen to do it.)
zw