[Toybox] [PATCH] file: don't be confused by BSS sections.

Rob Landley rob at landley.net
Wed Mar 16 04:46:54 PDT 2022


On 3/15/22 9:30 PM, enh via Toybox wrote:
> BSS sections are *expected* to claim a larger size than is actually
> present in the file. Unlike program headers which have two different
> size fields for the memory and file sizes, sections headers only have
> one size field, so we're using the right field; we just need to ignore
> it for our overflow checking purposes.

Applied, but do you have a test for the old behavior?

$ ./toybox file toybox
toybox: ELF shared object, 64-bit LSB x86-64, dynamic (/lib64/ld-linux-x86-64.so.2)

Didn't complain? How about...

$ cat hello.c
int is_potato[10000000];

int main(int argc, char *argv[])
{
  is_potato[9999999] = 42;

  return is_potato[9999999];
}
$ gcc hello.c
$ ./toybox file a.out
a.out: ELF shared object, 64-bit LSB x86-64, dynamic
(/lib64/ld-linux-x86-64.so.2), BuildID=de3b2aca1f5e99bad5746ca0dd9754a6a6104050
$ echo $?
0
$ readelf -a ./a.out | grep bss -A 1 | head -n 2
  [24] .bss              NOBITS           0000000000004040  00003028
       0000000002625a20  0000000000000000  WA       0     0     32

Rob


More information about the Toybox mailing list