[PATCH] D90897: [llvm-objcopy] --only-keep-debug: place zero-size segment according to its parent segment

Elliott Hughes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 12:50:56 PST 2020


enh added a comment.

In D90897#2385929 <https://reviews.llvm.org/D90897#2385929>, @MaskRay wrote:

> In D90897#2385176 <https://reviews.llvm.org/D90897#2385176>, @jhenderson wrote:
>
>> In D90897#2379198 <https://reviews.llvm.org/D90897#2379198>, @MaskRay wrote:
>>
>>> In D90897#2378385 <https://reviews.llvm.org/D90897#2378385>, @jhenderson wrote:
>>>
>>>> Won't this fail if the PT_LOAD the PT_TLS should be in has a zero size too?
>>>
>>> PT_LOAD with p_memsz is invalid on Linux. Attempting to mmap a zero-sized segment will fail.
>
> It is both Linux and FreeBSD (according to rL288808 <https://reviews.llvm.org/rL288808>). LLD has removeEmptyPTLoad.
>
>> This is an implementation detail that won't necessarily be true for all systems. Kernels could also quite happily ignore zero-sized segments with a trivial piece of code to check the size before calling mmap.

that might have been sensible ... but POSIX actually _requires_ that an mmap() of length 0 fails with EINVAL (it's a "shall fail", not just a "may fail": https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90897/new/

https://reviews.llvm.org/D90897



More information about the llvm-commits mailing list