Board.KolibriOS.org

Official KolibriOS board
It is currently Sat Oct 19, 2019 7:44 am

All times are UTC+03:00




Post new topic  Reply to topic  [ 226 posts ]  Go to page Previous 112 13 14 15 16 Next
Author Message
 Post subject: Re: Newlib
PostPosted: Sat Feb 18, 2017 2:28 pm 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
netryx
Code:
buf->st_ino=(unsigned)rand();
У меня вопрос возник. Если использовать rand() при каждом вызове для одного файла будет генерироваться новое значение. Это не создаст проблем?


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Feb 18, 2017 3:16 pm 
Offline

Joined: Thu Mar 31, 2016 10:18 am
Posts: 11
Может быть и создаст. В приведенном мной примере ошибка может получится, если попытаться в tar файл запихнуть этот же tar файл. То есть, если заданы неверные параметры. Во многих приложениях st_ino не требуется, там проблем не будет. Если делать st_ino по хэш сумме абсолютного пути файла в нижнем регистре (если это не ext ФС), то и это в каких то случаях может привести к ошибке, но вероятность этого низкая. Мой код не совсем правильный, делал на скорую руку, st_ino меня тогда не сильно заботило, но он хоть как-то пытается определить корневые папки, как каталоги. Да и ошибка будет, если реально не существует /hd0/5 , но моя функция вернет что есть. Я это делал, чтобы заставить работать busybox, и это (lstat) будет работать, если в командную строку busybox не указывать неправильные параметры.


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Feb 23, 2017 1:09 pm 
Offline

Joined: Thu Jan 19, 2017 11:48 am
Posts: 10
Подскажите, как собрать библиотеку в cygwin?

_________________
О, что-то новенькое!


Top
   
 Post subject: Re: Newlib
PostPosted: Tue Feb 28, 2017 7:02 pm 
Offline
Mentor/Kernel Developer
User avatar

Joined: Thu Mar 26, 2015 5:16 pm
Posts: 1264
revision #6868
Починил для FAT.


Top
   
 Post subject: Re: Newlib
PostPosted: Mon Mar 06, 2017 5:34 pm 
Offline
Mentor/Kernel Developer
User avatar

Joined: Thu Mar 26, 2015 5:16 pm
Posts: 1264
revision #6875
Теперь 70.5 должна поддерживать всё.


Top
   
 Post subject: Re: Newlib
PostPosted: Fri Mar 31, 2017 6:14 pm 
Offline
Designer
User avatar

Joined: Thu Jan 25, 2007 3:33 pm
Posts: 5062
Воу, воу, воу. Вот это уже круто и интересно.
Надо будет запилить.

_________________
Через тернии к звездам


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Apr 06, 2017 1:53 am 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
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?

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Apr 06, 2017 10:58 am 
Offline

Joined: Tue Mar 08, 2016 11:00 pm
Posts: 436
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


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Apr 08, 2017 1:58 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
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?

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Apr 08, 2017 6:34 pm 
Offline

Joined: Tue Mar 08, 2016 11:00 pm
Posts: 436
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


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Apr 13, 2017 9:34 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
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!

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Apr 22, 2017 1:42 am 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
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?

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Apr 22, 2017 5:06 pm 
Offline
Mentor/Kernel Developer
User avatar

Joined: Fri Jun 30, 2006 9:01 am
Posts: 1248
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.

_________________
"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." Albert Einstein


Top
   
 Post subject: Re: Newlib
PostPosted: Sun Apr 23, 2017 3:29 pm 
Offline
Mentor/Kernel Developer
User avatar

Joined: Thu Mar 26, 2015 5:16 pm
Posts: 1264
Yes, currently argv[0] contains the encoding marker (3 = UTF-8), but all sysfunctions support such input. So, what might cause the problem?


Top
   
 Post subject: Re: Newlib
PostPosted: Fri Apr 28, 2017 10:31 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
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.

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 226 posts ]  Go to page Previous 112 13 14 15 16 Next

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited