Newlib

Discussing libraries simplifying applications development
  • Может быть и создаст. В приведенном мной примере ошибка может получится, если попытаться в tar файл запихнуть этот же tar файл. То есть, если заданы неверные параметры. Во многих приложениях st_ino не требуется, там проблем не будет. Если делать st_ino по хэш сумме абсолютного пути файла в нижнем регистре (если это не ext ФС), то и это в каких то случаях может привести к ошибке, но вероятность этого низкая. Мой код не совсем правильный, делал на скорую руку, st_ino меня тогда не сильно заботило, но он хоть как-то пытается определить корневые папки, как каталоги. Да и ошибка будет, если реально не существует /hd0/5 , но моя функция вернет что есть. Я это делал, чтобы заставить работать busybox, и это (lstat) будет работать, если в командную строку busybox не указывать неправильные параметры.
  • Подскажите, как собрать библиотеку в cygwin?
    О, что-то новенькое!
  • revision #6868
    Починил для FAT.
  • revision #6875
    Теперь 70.5 должна поддерживать всё.
  • Воу, воу, воу. Вот это уже круто и интересно.
    Надо будет запилить.
    Из хаоса в космос
  • 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!
  • 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
  • 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!
  • 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
  • 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!
  • 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!
  • 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
  • Yes, currently argv[0] contains the encoding marker (3 = UTF-8), but all sysfunctions support such input. So, what might cause the problem?
  • 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!
  • Who is online

    Users browsing this forum: No registered users and 4 guests