elf obj load: skip zero-sized sections early

Bjoern A. Zeeb bzeeb-lists at lists.zabbadoz.net
Mon Jul 5 17:15:09 UTC 2010


On Mon, 5 Jul 2010, Andriy Gapon wrote:

> on 02/07/2010 11:29 Bjoern A. Zeeb said the following:
>> On Fri, 25 Jun 2010, Andriy Gapon wrote:
>>
>> Hey,
>>
>>> Proposed patch skips zero sized sections without going into trouble of
>>> allocating section entry (progtab), doing zero-sized memory allocs and
>>> copies.
>>> I observe that sometimes zero-sized set_pcpu sections are produced in
>>> module
>>> objects, maybe when a module doesn't create any per cpu data of its
>>> one, but
>>> references external pcpu data.  Not sure.
> [snip]
>>> This work is based on np@'s investigation and original patch:
>>> http://lists.freebsd.org/pipermail/freebsd-hackers/2009-November/030093.html
>>>
>>
>> Have you guys figured this out already?
>
> By 'this' - do you mean why that zero-sized section is produced at all?
> Does it really matter why that happens?

Well, no, I was thinking of the workaround and going ahead to commit
somehting;)


> I stated my guess already.  Now I see that it is enough to simply include
> sys/pcpu.h for this to happen.  Inline assembly at the start of the said header
> unconditionally creates the section.  If DPCPU_DEFINE is never used in a module,
> then set_pcpu section remains empty.  Neither compiler nor linker have any reason
> to drop empty sections in the build process for amd64 modules.
>
> I am not sure if ".section set_pcpu" assembly can be made conditional or moved
> some place else, so that the section is only created when DPCPU_DEFINE is actually
> used.

The same applies to VIMAGE btw.  Same technique.

/bz

-- 
Bjoern A. Zeeb    From August on I will have a life.  It's now up to you
to do the maths and count to 64.     -- Bondorf, Germany, 14th June 2010


More information about the freebsd-hackers mailing list