[lld] r228381 - [Core] Update ContentPermissions

Rui Ueyama ruiu at google.com
Fri Feb 6 12:53:27 PST 2015


So, why? The fact that X could do Y doesn't mean that we should make X do Y.

MachO actually uses this as a bitmap to check if an atom has RW bits set.
If you make this non-bitmask, you'd have to do (perm == RW || perm == RWX
|| perm == RWXL) instead of ((perm & RW) == RW). And even worse, you'd have
to update the statement every time you add a new permission to your enum.

On Fri, Feb 6, 2015 at 12:18 PM, Shankar Easwaran <shankare at codeaurora.org>
wrote:

> Hi,
>
> The permission enums in the DefinedAtom could no more be a bitmask.
>
> The writer could create a map of the enum variables to the exact bit
> representation that the format cares about.
>
> Shankar Easwaran
>
>
> On 2/6/2015 1:41 PM, Rui Ueyama wrote:
>
>> I don't get it. What do you mean by "all permissions map need to be done
>> in
>> the writer"? Is that related to making the permission enums non-bitmask?
>>
>> On Fri, Feb 6, 2015 at 6:58 AM, Shankar Easwaran <shankare at codeaurora.org
>> >
>> wrote:
>>
>>  Reverted this patch. I think all the permissions map need to be done in
>>> the writer.
>>>
>>>
>>> On 2/5/2015 11:48 PM, Rui Ueyama wrote:
>>>
>>>  This needed a pre-commit review. Obviously they are bitmasks just like
>>>> Unix
>>>> file permission. Not sure we want to lose that characteristic.
>>>>
>>>> On Thu, Feb 5, 2015 at 9:29 PM, Shankar Easwaran <
>>>> shankare at codeaurora.org
>>>> wrote:
>>>>
>>>>   Author: shankare
>>>>
>>>>> Date: Thu Feb  5 23:29:49 2015
>>>>> New Revision: 228381
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=228381&view=rev
>>>>> Log:
>>>>> [Core] Update ContentPermissions
>>>>>
>>>>> The values are already arranged in ascending order, and all tests still
>>>>> pass.
>>>>>
>>>>> Removing the values as its confusing when new enumerations need to be
>>>>> added.
>>>>>
>>>>> Modified:
>>>>>       lld/trunk/include/lld/Core/DefinedAtom.h
>>>>>
>>>>> Modified: lld/trunk/include/lld/Core/DefinedAtom.h
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/
>>>>> Core/DefinedAtom.h?rev=228381&r1=228380&r2=228381&view=diff
>>>>>
>>>>> ============================================================
>>>>> ==================
>>>>> --- lld/trunk/include/lld/Core/DefinedAtom.h (original)
>>>>> +++ lld/trunk/include/lld/Core/DefinedAtom.h Thu Feb  5 23:29:49 2015
>>>>> @@ -157,14 +157,14 @@ public:
>>>>>      // important, because the layout pass may sort atoms by
>>>>> permission if
>>>>> other
>>>>>      // attributes are the same.
>>>>>      enum ContentPermissions {
>>>>> -    perm___  = 0,           // mapped as unaccessible
>>>>> -    permR__  = 8,           // mapped read-only
>>>>> -    permRW_  = 8 + 2,       // mapped readable and writable
>>>>> -    permRW_L = 8 + 2 + 1,   // initially mapped r/w, then made
>>>>> read-only
>>>>> -                            // loader writable
>>>>> -    permR_X  = 8 + 4,       // mapped readable and executable
>>>>> -    permRWX  = 8 + 2 + 4,   // mapped readable and writable and
>>>>> executable
>>>>> -    permUnknown = 16        // unknown or invalid permissions
>>>>> +    perm___,           // mapped as unaccessible
>>>>> +    permR__,           // mapped read-only
>>>>> +    permRW_,           // mapped readable and writable
>>>>> +    permRW_L,           // initially mapped r/w, then made read-only
>>>>> +                        // loader writable
>>>>> +    permR_X,            // mapped readable and executable
>>>>> +    permRWX,            // mapped readable and writable and executable
>>>>> +    permUnknown         // unknown or invalid permissions
>>>>>      };
>>>>>
>>>>>      enum SectionChoice {
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>
>>>>>
>>>>>  --
>>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
>>> by the Linux Foundation
>>>
>>>
>>>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by the Linux Foundation
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150206/7a65f5f5/attachment.html>


More information about the llvm-commits mailing list