[PATCH] [lld][PECOFF] Take into account all sections when setting size fields in the PE header

Rui Ueyama ruiu at google.com
Fri Sep 13 12:19:10 PDT 2013


An executable does not contain a bunch of sections but usually only a few,
so there's no performance concern on looping over them. For readability I
prefer having a separate loop rather than mixing output and counting in one
loop.


On Fri, Sep 13, 2013 at 11:30 AM, Shankar Easwaran
<shankare at codeaurora.org>wrote:

> Cant this be done while you write the output file. You need to write every
> section anyways and you can avoid these loops.
>
> Thanks
>
> Shankar Easwaran
>
>
> On 9/13/2013 1:03 PM, Rui Ueyama wrote:
>
>>
>> ================
>> Comment at: lib/ReaderWriter/PECOFF/**WriterPECOFF.cpp:472
>> @@ +471,3 @@
>> +
>> +  virtual bool isCodeSection() {
>> +    return _sectionHeader.Characteristics & llvm::COFF::IMAGE_SCN_CNT_**
>> CODE;
>> ----------------
>> Why virtual?
>>
>> ================
>> Comment at: lib/ReaderWriter/PECOFF/**WriterPECOFF.cpp:923
>> @@ +922,3 @@
>> +
>> +  uint64_t calcSizeOfInitializedData() {
>> +    uint64_t ret = 0;
>> ----------------
>> I'd define a helper function calculateSectionSize(**SectionCharacteristics)
>> containing the for loop and use it in the following three functions, rather
>> than repeating the same loop three times.
>>
>>
>> http://llvm-reviews.chandlerc.**com/D1616<http://llvm-reviews.chandlerc.com/D1616>
>> ______________________________**_________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<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
>
>
> ______________________________**_________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130913/d741d533/attachment.html>


More information about the llvm-commits mailing list