[PATCH] D17817: [ELF] do not allow .bss to occupy the file space when producing relocatable output.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 11:32:11 PST 2016


On 2 March 2016 at 12:26, Rui Ueyama <ruiu at google.com> wrote:
> ruiu added inline comments.
>
> ================
> Comment at: ELF/Writer.cpp:1325
> @@ -1324,1 +1324,3 @@
> +      FileOff = alignTo(FileOff, Sec->getAlign());
>      Sec->setFileOffset(FileOff);
> +    if (Sec->getType() != SHT_NOBITS)
> ----------------
> Do you have to set file offsets to bss sections?


The spec says:

----------------------------------------
One section type, SHT_NOBITS described below, occupies no space in the
file, and its sh_offset member locates the conceptual placement in the
file.
----------------------------------------

As far as I can tell every producer of .o files does it. I tested gas,
llvm-mc, "ld.bfd -r" and "ld.gold -r", so I think we should set it
too.

Cheers,
Rafael


More information about the llvm-commits mailing list