Date: Tue, 24 Nov 2009 10:29:38 -0800 From: Navdeep Parhar <nparhar@gmail.com> To: freebsd-hackers@freebsd.org Subject: zero size set_pcpu linker sets Message-ID: <d04e16b70911241029q41fb4f8au12574763d9a8eb99@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
objdump -h shows that most, but not all, KLDs on amd64 have a "set_pcpu" section of size 0. Why? What is the difference between having a 0 sized set_pcpu vs. not having it at all? The kernel linker considers the alignment requirements of these empty sections and advances mapsize/mapbase. This bothers my kgdb (which is slightly modified to deal with amd64 KLDs). I'm using the patch shown here as a stopgap measure. I think the correct fix is to not have these empty sections in the KLD to begin with. Regards, Navdeep diff -r 09b877bb00f2 sys/kern/link_elf_obj.c --- a/sys/kern/link_elf_obj.c Mon Nov 23 12:42:09 2009 -0800 +++ b/sys/kern/link_elf_obj.c Tue Nov 24 10:13:02 2009 -0800 @@ -680,10 +680,12 @@ switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: - alignmask = shdr[i].sh_addralign - 1; - mapsize += alignmask; - mapsize &= ~alignmask; - mapsize += shdr[i].sh_size; + if (shdr[i].sh_size) { + alignmask = shdr[i].sh_addralign - 1; + mapsize += alignmask; + mapsize &= ~alignmask; + mapsize += shdr[i].sh_size; + } break; } } @@ -740,9 +742,15 @@ switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: - alignmask = shdr[i].sh_addralign - 1; - mapbase += alignmask; - mapbase &= ~alignmask; + if (shdr[i].sh_size) { + alignmask = shdr[i].sh_addralign - 1; + mapbase += alignmask; + mapbase &= ~alignmask; + } if (ef->shstrtab && shdr[i].sh_name != 0) ef->progtab[pb].name = ef->shstrtab + shdr[i].sh_name;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d04e16b70911241029q41fb4f8au12574763d9a8eb99>