[NSWI004] objdump complains about .bss size
Petr Tůma
petr.tuma at d3s.mff.cuni.cz
Mon Oct 12 15:02:44 CEST 2020
Hi,
the `.bss` section is a bit special - it is used to store variables whose content is initialized to zero, and therefore its content is not saved in the executable file (it does not need to be, the loader just looks at the section size and fills the required block with zeros). (In the list of sections produced by `objdump -h`, you may notice that `.bss` does not have any content, see also https://stackoverflow.com/questions/11196048/flags-in-objdump-output-of-object-file.)
The particular source file includes a rather large (~150 MB) array that is in the `.bss` section, and the `-D` flag you use with `objdump` tells it to ignore the section flags and try to disassemble everything, which is why you see the error message. Since `.bss` does not contain any code, you can most likely ignore the message (by the way, you may want to skip disassembling and just look at the code size, as the question suggests).
Petr
On 12/10/2020 12:13, Káně, Vojtěch wrote:
> Hello,
> I hope this question is fine given it relates to a current graded quiz.
>
> I was trying to answer Q5. Using the instruction, I downloaded a piece
> of code and compiled it both as PIE (`g++ -fpie -fpic -o pi code.cc`)
> and not PIE (`g++ -fno-pie -fno-pic -o nopi code.cc`).
>
> When I run `objdump -D file` no matter on which of the executables
> (hope this is not spoiling too much), I get reasonably looking output,
> however stderr contains:
>
> objdump: error: nopi(.bss) section size (0x8000128 bytes) is larger
> than file size (0x4ed8 bytes)
> objdump: Reading section .bss failed because: memory exhausted
>
> What is the cause of the problem? Can I safely ignore it?
>
> Thank you in advance,
> Vojtěch Káně
> _______________________________________________
> NSWI004 mailing list
> NSWI004 at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/nswi004
>
More information about the NSWI004
mailing list