Board.KolibriOS.org

Official KolibriOS board
It is currently Fri Jul 19, 2019 7:24 am

All times are UTC+03:00




Post new topic  Reply to topic  [ 226 posts ]  Go to page Previous 111 12 13 14 15 16 Next
Author Message
 Post subject: Re: Newlib
PostPosted: Thu Nov 13, 2014 2:05 pm 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
pascualle
Странно. Я думаю у тебя изменены локальные файлы.
Code:
yacc  glcpp/glcpp-parse.y
Этой строчки при сборке не должно было быть. Скорее всего у тебя другие glcpp-parse.c и glcpp-lex.c. Проверь дерево Mesa на модификацию.


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Nov 13, 2014 2:12 pm 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
Лог сборки Mesa


Attachments:
mesa-build.7z [10.33 KiB]
Downloaded 134 times
Top
   
 Post subject: Re: Newlib
PostPosted: Thu Nov 13, 2014 2:48 pm 
Offline
User avatar

Joined: Sat Jul 05, 2014 11:15 am
Posts: 88
ок, удалю вечером все, соберусь по чистому и отпишусь

upd:
удалил все, взял последнюю,
Code:
D:\kolibri\contrib
At revision: 5176

версию

Запустил все собирать как писал раньше, ошибка все та же...
Пока идей нет


Top
   
 Post subject: Re: Newlib
PostPosted: Wed Nov 26, 2014 4:21 am 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
pascualle
Проблема решилась ?
Мне не удалось воспроизвести ошибку. Для проверки сделал экспорт contrib #5141 и собрал под msys и debian linux. Разницы нет, всё собирается (хотя mesa линкуется несколько раз, где-то косяк с зависимостями)


Attachments:
File comment: Полные логи сборки sdk
build_sdk.7z [26.48 KiB]
Downloaded 132 times
Top
   
 Post subject: Re: Newlib
PostPosted: Wed Nov 26, 2014 10:44 am 
Offline
User avatar

Joined: Sat Jul 05, 2014 11:15 am
Posts: 88
(правка: удалено по причине не верной информации сообщения)


Last edited by pascualle on Fri Nov 28, 2014 1:10 am, edited 1 time in total.

Top
   
 Post subject: Re: Newlib
PostPosted: Wed Nov 26, 2014 3:35 pm 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
pascualle
Чудеса. У меня есть и yacc и bison. Я знаю, что они не должны вызываться. Сам писал мейкфайлы.
Ты можешь сделать лог полной сборки mesa с yacc и bison?


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Nov 27, 2014 6:47 am 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
В #5190 добавил разбивку командной строки на параметры
Скомпилированные DLL и библиотеки импорта
Spoiler: Show
Attachment:
cmdline.png
cmdline.png [ 9.28 KiB | Viewed 3414 times ]


Top
   
 Post subject: Re: Newlib
PostPosted: Thu Nov 27, 2014 12:23 pm 
Offline
User avatar

Joined: Sat Jul 05, 2014 11:15 am
Posts: 88
Serge,
нашел причину: затесался cygwin/bin в переменную PATH
(моя беда -- другим наука)


Top
   
 Post subject: Re: Newlib
PostPosted: Fri Aug 28, 2015 11:16 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
Hello,

I've been playing with newlib and the cross compiler for some time now. I decided to write some C and assembly code that would enable us to have "wrappers" for calling assembly libraries (http.obj, box_lib.obj and others) directly from C. Since I don't use Windows, I'm trying to avoid the MS COFF format, and sticking to the COFF format.

dll.asm :

Code:
 __DEBUG__       = 1
__DEBUG_LEVEL__ = 1

format coff
use32                                   ; Tell compiler to use 32 bit instructions


include 'struct.inc'
include 'proc32.inc'
include 'macros.inc'
purge section,mov,add,sub
include 'debug-fdo.inc'

include 'network.inc'
include 'http.inc'
include 'dll.inc'
   
public init_network as '_init_network'
public dll.Load as '_dll_load'
   
section '.flat' code   
   
proc init_network
   
   mcall 68,11
   
   stdcall dll.Load, @IMPORT
   ;; stdcall new_dll_load, @IMPORT
        test    eax, eax
        jnz     error
   
   mov eax, 0xAABBCCDD
   mcall -1
   
error:   
   mov eax, 0xEEFF8899
   mcall -1
endp   
   
@IMPORT:
library lib_http,               'http.obj'

import  lib_http, \
        HTTP_get,               'get', \
        HTTP_post,              'post', \
        HTTP_receive,           'receive', \
        HTTP_find_header_field, 'find_header_field', \
        HTTP_free,              'free', \
        HTTP_escape,            'escape'


dll.c
Code:
extern void init_network(void);

int main()
{
  __asm__ volatile("int3"::);
  init_network();
  __asm__ volatile("int3"::);

  return 0;
}


Compiling with :


alias kgcc='~/i586-kos32/kos32/bin/i586-kos32-gcc -I/home/user/kolibrios/contrib/sdk/sources/newlib/libc/include'

fasm dll.asm dll.obj
kgcc dll.c dll.obj -o DLLFILE

Shifting this DLLFILE to KolibriOS. The program starts running, but the address for the CALL instruction in the final executable is wrong. It points to a few bytes before the address of where dll.Load procedure is loaded. In my case, The dll.Load is at address 0xC460 but the STDCALL dll.Load line calls the address 0xC44A .

Using mtdbg, if I fix the address from 0xC44A to 0xC460, the library loading seems to work fine (evident from correct value loaded into EAX). What could be going wrong?

Thanks.

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


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Aug 29, 2015 1:59 am 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
Hi again.

I've written some code to interface C with our assembly network library procedures and it feels good to see C being able to load libraries at run time. Binary for Kolibri is also attached to post.

dllhttp.asm:

Code:
 __DEBUG__       = 1
__DEBUG_LEVEL__ = 1

format coff
use32                                   ; Tell compiler to use 32 bit instructions


include 'struct.inc'
include 'proc32.inc'
include 'macros.inc'
purge section,mov,add,sub
include 'debug-fdo.inc'

include 'network.inc'
include 'http.inc'
include 'dll.inc'
   
virtual at 0
        http_msg http_msg
end virtual

public init_network as '_init_network'
public open_site as '_open_site'
public dll.Load as '_dll_load'
public dll.Link as '_dll_link'
public dll.Init as '_dll_init'
public mem.Alloc as '_mem_alloc'
public mem.ReAlloc as '_mem_realloc'

section '.flat' code   
   
proc init_network
   
   mcall 68,11
   
   stdcall dll.Load, @IMPORT
   ;; stdcall new_dll_load, @IMPORT
        test    eax, eax
        jnz     error
   
   mov eax, 0xAABBCCDD
   ret
   
error:   
   mov eax, 0xEEFF8899
   mcall -1
endp   
   
proc open_site
   mov eax, identifier
   invoke  HTTP_get, sz_url, 0, 0, 0
        test    eax, eax
        jz      error2
        mov     [identifier], eax

  .again:
        invoke  HTTP_receive, [identifier]
        test    eax, eax
        jnz     .again
   
   mov eax, [identifier]
   add eax, 32
   mov ebx, [eax]
   
   int3
   DEBUGF 1, "The content is : %s", ebx
   ret
   
error2:
   mcall -1
endp   

@IMPORT:
   
library lib_http,               'http.obj'

import  lib_http, \
        HTTP_get,               'get', \
        HTTP_post,              'post', \
        HTTP_receive,           'receive', \
        HTTP_find_header_field, 'find_header_field', \
        HTTP_free,              'free', \
        HTTP_escape,            'escape'

public HTTP_get as '_http_get'
public HTTP_post as '_http_post'
public HTTP_receive as '_http_receive'
public HTTP_find_header_field as '_http_find_header_field'
public HTTP_free as '_http_free'
public HTTP_escape as '_http_escape'
   
sz_url                  db 'http://www.ashmew2.me'
identifier              dd 0
include_debug_strings


dllhttp.c:

Code:
extern void init_network(void);
extern void open_site(void);

#define NULL 0

int main()
{

  __asm__ volatile("int3"::);

  init_network();
  open_site();

  return 0;
}




Compile/Link as usual and run the binary.

To get your hands dirty without compiling, this is how you should run the binary in MTDBG:

Code:
  load dllhttpbin
  g
  bp c463
  g
  r eip=c479
  g
  d eax
  <Now keep pressing d to see the site's content>
  g


Attachments:
File comment: binary for KolibriOS
dllhttp [49.79 KiB]
Downloaded 107 times

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Top
   
 Post subject: Re: Newlib
PostPosted: Tue Sep 01, 2015 11:29 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
Fixed the address issue for CALL instructions by moving the line
Code:
section '.flat' code


to before the line where we include all .inc files

This fixes the issue and I was able to create a wrapper for calling http.obj procedures as C functions.
Thank you for the cross compiler, Serge. It has really made life easier ;)

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


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Jan 30, 2016 5:04 pm 
Offline

Joined: Wed Jan 20, 2016 10:37 am
Posts: 4
Здравствуйте. У меня Linux Mint 32bit. Поставил mingw под wine 1.8, закинул libiconv-2 в ~/.wine/drive_c/MinGW/msys/1.0/home/autobuild/tools/win32/bin/, в ~/.wine/drive_d/ - папочку kolibri/sdk (как в статье "Пишем на языке С/C++ в Windows под KolibriOS / Хабрахабр"). Получаю ошибки при компиляции libc и примера:

$ export PATH=$PATH:/home/autobuild/tools/win32/bin
$ cd /d/kolibri/contrib/sdk/sources/newlib/libc
$ make shared
kos32-gcc -c -O2 -fno-ident -fomit-frame-pointer -fexceptions -DBUILD_DLL -DMISSING_SYSCALL_NAMES -D_IEEE_LIBM -DHAVE_RENAME -I ./include -o crt/crtdll.o crt/crtdll.c
make: *** [crt/crtdll.o] Error 1

$ cd /d/work
$ make
kos32-gcc -c -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -
U__MINGW32__ -U_MSC_VER -I/d/kolibri/contrib/sdk/sources/newlib/libc/include -o
simple.o simple.c
make: *** [simple.o] Error 1


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Jan 30, 2016 5:33 pm 
Offline
Kernel Developer

Joined: Wed Mar 08, 2006 6:25 pm
Posts: 3952
AlexKaz
Не знаю чем помочь. Wine я не пользовался. А Msys установлен, или только папка есть ?
Если надо я могу написать, как собрать косскомпилятор.


Top
   
 Post subject: Re: Newlib
PostPosted: Sat Jan 30, 2016 5:47 pm 
Offline

Joined: Wed Jan 20, 2016 10:37 am
Posts: 4
Оо, всё отлично, понадобилось скопировать все библиотеки из ~/.wine/drive_c/MinGW/bin/ в ~/.wine/drive_c/MinGW/msys/1.0/home/autobuild/tools/win32/bin/ =) и fasm.exe воткнуть туда же..


Top
   
 Post subject: Re: Newlib
PostPosted: Wed Mar 09, 2016 6:02 pm 
Offline
Mentor

Joined: Tue Mar 11, 2014 11:37 am
Posts: 184
Hi

This is regarding the isspace() function in C:

If I build the spacer.c file with this process:

kos32-gcc -c -I/home/bob/kolibrios/contrib/sdk/sources/newlib/libc/include -g -U_Win32 -U_WIN32 -U__MINGW32__ space.c kolibri_debug.c

kos32-ld space.o kolibri_debug.o -T/home/bob/kolibrios/contrib/sdk/sources/newlib/libc/app.lds -nostdlib -static --image-base 0 -lgcc -L/home/autobuild/tools/win32/mingw32/lib /home/autobuild/tools/win32/lib/libdll.a /home/autobuild/tools/win32/lib/libapp.a /home/autobuild/tools/win32/lib/libc.dll.a -static -o spacer

objcopy -O binary spacer

If I run this file on Kolibri, isspace() shows False for all integers in 0-10 except 0.
10 should be true. Right?
It also returns true for isspace('a').

I checked the implementation of isspace.c / isspace() function, and it seems like it does

Code:
#define _S 010

int _DEFUN(isspace,(c),int c)
{
   return(__ctype_ptr__[c+1] & _S);
}


Is this correct?


Attachments:
File comment: Binary to run on Kolibri
spacer [1.71 KiB]
Downloaded 80 times
File comment: debug file for debug_board_write_str
kolibri_debug.c [318 Bytes]
Downloaded 78 times
File comment: Source code
space.c [574 Bytes]
Downloaded 80 times

_________________
---
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 111 12 13 14 15 16 Next

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 1 guest


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