[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ARM readdir returning overflow
From: |
Paulo Matos |
Subject: |
ARM readdir returning overflow |
Date: |
Wed, 08 Jan 2020 15:13:24 +0100 |
User-agent: |
mu4e 1.3.5; emacs 26.3 |
Hi,
I was preparing an example of using qemu with an arm binary and got an
unexpected result. With a cross-compiler from crosstool-ng for armv7:
$ armv7-rpi2-linux-gnueabihf-gcc --version
armv7-rpi2-linux-gnueabihf-gcc (crosstool-NG 1.24.0) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
With this example (listdir.c):
$ cat > listdir.c<<EOF
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
int main(void)
{
struct dirent *de;
DIR *dr = opendir("/");
while ((de = readdir(dr)) != NULL)
printf("%s\n", de->d_name);
closedir(dr);
return 0;
}
EOF
After statically compiling, when I run qemu 4.1.0:
$ armv7-rpi2-linux-gnueabihf-gcc -static -o listdir listdir.c
$ qemu-arm ./listdir
$
Nothing happens, if you do a perror("") on the readdir call (which is
returning NULL), you get the error:
Value too large for defined data type
Could this be a bug in the arm backend for qemu or a misunderstanding on
my part?
Regards,
Paulo Matos
- ARM readdir returning overflow,
Paulo Matos <=