Page 15 of 16

Re: Newlib

Posted: Sat Feb 18, 2017 2:28 pm
by Serge
netryx

Code: Select all

buf->st_ino=(unsigned)rand();
У меня вопрос возник. Если использовать rand() при каждом вызове для одного файла будет генерироваться новое значение. Это не создаст проблем?

Re: Newlib

Posted: Sat Feb 18, 2017 3:16 pm
by netryx
Может быть и создаст. В приведенном мной примере ошибка может получится, если попытаться в tar файл запихнуть этот же tar файл. То есть, если заданы неверные параметры. Во многих приложениях st_ino не требуется, там проблем не будет. Если делать st_ino по хэш сумме абсолютного пути файла в нижнем регистре (если это не ext ФС), то и это в каких то случаях может привести к ошибке, но вероятность этого низкая. Мой код не совсем правильный, делал на скорую руку, st_ino меня тогда не сильно заботило, но он хоть как-то пытается определить корневые папки, как каталоги. Да и ошибка будет, если реально не существует /hd0/5 , но моя функция вернет что есть. Я это делал, чтобы заставить работать busybox, и это (lstat) будет работать, если в командную строку busybox не указывать неправильные параметры.

Re: Newlib

Posted: Thu Feb 23, 2017 1:09 pm
by aristarh2704
Подскажите, как собрать библиотеку в cygwin?

Re: Newlib

Posted: Tue Feb 28, 2017 7:02 pm
by Pathoswithin
revision #6868
Починил для FAT.

Re: Newlib

Posted: Mon Mar 06, 2017 5:34 pm
by Pathoswithin
revision #6875
Теперь 70.5 должна поддерживать всё.

Re: Newlib

Posted: Fri Mar 31, 2017 6:14 pm
by Leency
Воу, воу, воу. Вот это уже круто и интересно.
Надо будет запилить.

Re: Newlib

Posted: Thu Apr 06, 2017 1:53 am
by ashmew2
Hi, With the latest toolchain based on GCC 5.x:

$ cat x.c
#include <sys/stat.h>

int main() {
mkdir("somedir", 0660);
return 0;
}

$ kos32-gcc -I ~/kolibrios/contrib/sdk/sources/newlib/libc/include/ -c -fno-ident -O2 -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 x.c

$ kos32-ld -static -Tapp-static.lds -L~/kolibrios/contrib/sdk/lib/ x.o -lc -lgcc -lc

x.o:x.c:(.text.startup+0x1e): undefined reference to `mkdir'

Any ideas what might be wrong?

Re: Newlib

Posted: Thu Apr 06, 2017 10:58 am
by Siemargl
This is not realized in newlib.
I make posix directory funclions for unzip, but not so clean code for including in newlib (unzip checked many times, though)

http://websvn.kolibrios.org/filedetails ... 2Fdirent.c

Re: Newlib

Posted: Sat Apr 08, 2017 1:58 pm
by ashmew2
Siemargl wrote:This is not realized in newlib.
I make posix directory funclions for unzip, but not so clean code for including in newlib (unzip checked many times, though)

http://websvn.kolibrios.org/filedetails ... 2Fdirent.c
That took care of the missing mkdir stuff..Would be nice to have this in newlib.

-----
Found another one:

$ cat x.c
#include <ctype.h>

int main() {
char *c = "abcd";
c[2] = toupper(c[1]);

return 0;
}

$ kos32-gcc -c -fno-ident -O2 -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -I$HOME/kolibrios/contrib/sdk/sources/newlib/libc/include x.c

$ kos32-ld -static -Tapp-static.lds -L$HOME/kolibrios/contrib/sdk/lib/ x.o -lc -lgcc -lc

$ x.o:x.c:(.text.startup+0xc): undefined reference to `_imp____ctype_ptr__'

Any ideas how to fix this?

Re: Newlib

Posted: Sat Apr 08, 2017 6:34 pm
by Siemargl
Try to link with libc.dll.a and dynamic.lds
$ kos32-ld -static -Tapp-dynamic.lds -L$HOME/kolibrios/contrib/sdk/lib/ x.o -lc -lgcc -lc.dll
may be need -ldll

Update:
If you wish to use static linking, add -DSTATIC_LIBC to compile options

Re: Newlib

Posted: Thu Apr 13, 2017 9:34 pm
by ashmew2
Thanks, compiling with dynamic lib instead of static gets it going for now.
Let's see how run time goes down :D

Update: The binary loads and using MTDBG can confirm that libc.dll is found and loaded at run time! Cheers!

Re: Newlib

Posted: Sat Apr 22, 2017 1:42 am
by ashmew2
Hi
Found a possible issue with value of argv array passed to main() :

Sample program :

$ cat x.c

#include <stdio.h>

int main(int argc, char *argv[]) {
fprintf(stderr, "argv[0] = %s\n", argv[0]);
return 0;
}

Compile with :
kos32-gcc -c -fno-ident -O2 -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -I$HOME/kolibrios/contrib/sdk/sources/newlib/libc/include x.c

kos32-ld -static -Tapp-static.lds -L$HOME/kolibrios/contrib/sdk/lib/ x.o -lc -lgcc -lc -o bin

objcopy -O binary bin

Executing this "bin" on kolibrios, when the program is run, the debug board shows :
/ /usbhd0/1/bin

This means that the value of argv[0] has a few extra characters at the beginning that it should not have.
Expected result : /usbhd0/1/bin (Just the path of the binary without extra bytes at the start).

Views?

Re: Newlib

Posted: Sat Apr 22, 2017 5:06 pm
by hidnplayr
It's likely that the library does not account for the fact that the path given to it by kernel might have a byte indicating the encoding of the string.

Re: Newlib

Posted: Sun Apr 23, 2017 3:29 pm
by Pathoswithin
Yes, currently argv[0] contains the encoding marker (3 = UTF-8), but all sysfunctions support such input. So, what might cause the problem?

Re: Newlib

Posted: Fri Apr 28, 2017 10:31 pm
by ashmew2
The problem was that I expected argv[0][2:] to be argv[0][0:] (without the encoding bytes)
Now that I know what it is, i can safely skip those bytes or do things in the code to use this information.