Re: [PATCH] libosd: Remove ignored __weak attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2018-10-02 at 15:33 -0700, Nick Desaulniers wrote:
+AD4 On Tue, Oct 2, 2018 at 10:57 AM Bart Van Assche +ADw-bvanassche+AEA-acm.org+AD4 wrote:
+AD4 +AD4 Explicitly initialized global and static variables end up in the .data
+AD4 +AD4 section and need space in that section.
+AD4 
+AD4 Unless the initial value is zero.
+AD4 https://godbolt.org/z/curRoO
+AD4 
+AD4 So you don't wind up with an increase in binary size simply by having
+AD4 global variables initialized to zero, right?  Instead the kernel knows
+AD4 to create a zero'd out mapping for bss.  You don't need a run of zeros
+AD4 in the binary.
+AD4 
+AD4 So I disagree when you said earlier +ACI-zero initializers should be left
+AD4 out to minimize the size of object files.+ACI I assert they don't affect
+AD4 the size of the binary.
+AD4 
+AD4 If you had many global variables all initialized to zero, why would
+AD4 you encode that many zeros in a binary, when you can just set a size
+AD4 on the bss section and have the kernel create the appropriate sized
+AD4 and zero'd mapping?
+AD4 
+AD4 +AD4 That is not the case if the
+AD4 +AD4 initializer is left out and these variables end up in the .bss section.
+AD4 
+AD4 From my above link, gcc will put globals without initializers into +ACI-common.+ACI

No matter what particular compiler versions do with explicit initialization
to zero, the preferred kernel coding style is to leave out such explicit
initialization.

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux