On Fri, Mar 8, 2019 at 10:57 AM Pekka Enberg <[email protected]> wrote:

> On Fri, Mar 8, 2019 at 10:42 AM Commit Bot <[email protected]>
> wrote:
>
>> From: Nadav Har'El <[email protected]>
>> Committer: Nadav Har'El <[email protected]>
>> Branch: master
>>
>> elf: support PT_GNU_PROPERTY segment type
>>
>> Recently, binutils added yet another segment type, called
>> "PT_GNU_PROPERTY":
>>
>> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0a59decbb81676ac30deede1bb6b6e241cd75502
>>
>> Since OSv's linker currently aborts when it sees an unknown segment type,
>> we saw crashes when loading some specific shared objects, like a recent
>> Java build from Fedora.
>>
>> This patch adds the missing segment type (and ignores it), and also
>> improves
>> the error message in case in the future we encounter more newly invented
>> segment types.
>>
>> Fixes #1030.
>>
>> Signed-off-by: Nadav Har'El <[email protected]>
>>
>> ---
>> diff --git a/core/elf.cc b/core/elf.cc
>> --- a/core/elf.cc
>> +++ b/core/elf.cc
>> @@ -423,15 +423,15 @@ void object::load_segments()
>>           case PT_GNU_RELRO:
>>           case PT_GNU_EH_FRAME:
>>           case PT_PAX_FLAGS:
>> +        case PT_GNU_PROPERTY:
>>               break;
>>           case PT_TLS:
>>               _tls_segment = _base + phdr.p_vaddr;
>>               _tls_init_size = phdr.p_filesz;
>>               _tls_uninit_size = phdr.p_memsz - phdr.p_filesz;
>>               break;
>>           default:
>> -            abort();
>> -            throw osv::invalid_elf_error("bad p_type");
>> +            abort("Unknown p_type in executable %s: %d\n", pathname(),
>> phdr.p_type);
>>
>
> Can't we always ignore unknown segment types, but print the above error
> message as a warning?
>

We could. Amusingly the old code had an abort() and *then* an attempt to
throw an error message instead of crashing, which obviously didn't do
anything.
I think it does make sense to print a warning message and then do nothing
(not crash and not even throw).
On the other hand, adding a new segment type is such a rare event (this is
the first time we encountered it in years) that maybe it is good that we do
think about every time it happens.


>
> - Pekka
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to