English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 22 July 2017, 14:17   #1
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
gcc sas/c link problem

i try to build a binary using gcc 2.95.3 and an object file (slib4.o) made by sas/c,
the result is some errors listed:
Code:
$ m68k-amigaos-g++.exe -g goo.cc -m68020 -m68881 -noixemul -ISDK/include slib4.o -o goo.p
hunk_drelx not supported yet
hunk_drelx not supported yet
hunk_drel16 not supported yet
hunk_drel16 not supported yet
slib4.o: file not recognized: No error
collect2: ld returned 1 exit status
can i convert or build slib4.o, so it will have compatible hunk types?

slib4.o:
Code:
0000  00 00 03 e7 00 00 00 02  73 6c 69 62 34 2e 63 00  |........slib4.c.|
0010  00 00 03 e8 00 00 00 01  74 65 78 74 00 00 03 e9  |........text....|
0020  00 00 00 1e 48 e7 00 0a  49 f9 00 00 00 00 30 7c  |....H...I.....0||
0030  00 04 29 50 00 00 43 ec  00 00 70 25 2c 78 00 04  |..)P..C...p%,x..|
0040  4e ae fd d8 29 40 00 04  67 20 61 00 00 00 4a 80  |N...)@..g a...J.|
0050  66 08 61 00 00 00 4a 80  66 12 61 00 00 00 22 6c  |f.a...J.f.a..."l|
0060  00 04 2c 78 00 04 4e ae  fe 62 70 00 4c df 50 00  |..,x..N..bp.L.P.|
0070  4e 75 48 e7 00 0a 49 f9  00 00 00 00 2f 2f 00 0c  |NuH...I.....//..|
0080  61 00 00 00 61 00 00 00  22 6c 00 04 2c 78 00 04  |a...a..."l..,x..|
0090  4e ae fe 62 58 4f 4c df  50 00 4e 75 00 00 03 f8  |N..bXOL.P.Nu....|
00a0  00 00 00 01 00 00 00 01  00 00 00 14 00 00 00 04  |................|
00b0  00 00 00 02 00 00 00 66  00 00 00 3c 00 00 00 22  |.......f...<..."|
00c0  00 00 00 10 00 00 00 00  00 00 03 ef 81 00 00 03  |................|
00d0  5f 4c 69 6e 6b 65 72 44  42 00 00 00 00 00 00 02  |_LinkerDB.......|
00e0  00 00 00 54 00 00 00 06  83 00 00 03 5f 5f 5f 66  |...T........___f|
00f0  70 69 6e 69 74 00 00 00  00 00 00 01 00 00 00 28  |pinit..........(|
0100  83 00 00 02 5f 53 74 61  72 74 75 70 00 00 00 01  |...._Startup....|
0110  00 00 00 30 83 00 00 03  5f 5f 5f 66 70 74 65 72  |...0....___fpter|
0120  6d 00 00 00 00 00 00 02  00 00 00 62 00 00 00 38  |m..........b...8|
0130  83 00 00 03 5f 53 68 75  74 64 6f 77 6e 00 00 00  |...._Shutdown...|
0140  00 00 00 01 00 00 00 5e  01 00 00 03 5f 5f 53 74  |.......^....__St|
0150  61 72 74 75 70 00 00 00  00 00 00 00 01 00 00 03  |artup...........|
0160  5f 5f 53 68 75 74 64 6f  77 6e 00 00 00 00 00 4e  |__Shutdown.....N|
0170  00 00 00 00 00 00 03 f1  00 00 00 03 00 00 00 00  |................|
0180  4f 50 54 53 00 04 00 40  00 00 03 f2 00 00 03 e8  |OPTS...@........|
0190  00 00 00 02 5f 5f 4d 45  52 47 45 44 00 00 03 ea  |....__MERGED....|
01a0  00 00 00 03 64 6f 73 2e  6c 69 62 72 61 72 79 00  |....dos.library.|
01b0  00 00 03 f2 00 00 03 e8  00 00 00 02 5f 5f 4d 45  |............__ME|
01c0  52 47 45 44 00 00 03 eb  00 00 00 02 00 00 03 ef  |RGED............|
01d0  01 00 00 02 5f 53 79 73  42 61 73 65 00 00 00 00  |...._SysBase....|
01e0  01 00 00 02 5f 44 6f 73  42 61 73 65 00 00 00 04  |...._DosBase....|
01f0  00 00 00 00 00 00 03 f2                           |........|
i'm using gcc 2.95.3 since it is able to compile the old source without any error message,
while gcc6.x reports lots of deprecated stuff. --std=c++98 does not help

i can build the goo.o object file without problem:
Code:
$ m68k-amigaos-g++.exe -g -c  goo.cc -m68020 -m68881 -noixemul -ISDK/include
i tried to use the goo.o object file on the amiga with sas/c to link it with sc/slink, but the object file is not recognized
Code:
0000  00 02 01 07 00 00 2a 9c  00 00 01 0c 00 00 00 18  |......*.........|
0010  00 00 5c c4 00 00 00 00  00 00 07 20 00 00 00 30  |..\........ ...0|
0020  4c 57 20 49 74 65 6d 20  49 6e 66 6f 20 32 00 4c  |LW Item Info 2.L|
0030  57 20 4f 62 6a 65 63 74  20 49 6e 66 6f 00 4c 57  |W Object Info.LW|
0040  20 42 6f 6e 65 20 49 6e  66 6f 00 4c 57 20 4c 69  | Bone Info.LW Li|
0050  67 68 74 20 49 6e 66 6f  20 32 00 4c 57 20 43 61  |ght Info 2.LW Ca|
0060  6d 65 72 61 20 49 6e 66  6f 00 4c 57 20 53 63 65  |mera Info.LW Sce|
0070  6e 65 20 49 6e 66 6f 20  32 00 4c 57 20 49 6d 61  |ne Info 2.LW Ima|
0080  67 65 20 4c 69 73 74 00  4c 57 20 43 6f 6d 70 6f  |ge List.LW Compo|
0090  73 69 74 69 6e 67 20 49  6e 66 6f 00 47 6c 6f 62  |siting Info.Glob|
00a0  61 6c 20 52 65 6e 64 65  72 20 4d 65 6d 6f 72 79  |al Render Memory|
00b0  00 49 6e 66 6f 20 4d 65  73 73 61 67 65 73 00 46  |.Info Messages.F|
00c0  69 6c 65 20 52 65 71 75  65 73 74 00 53 79 73 74  |ile Request.Syst|
00d0  65 6d 20 49 44 00 4e 55  00 00 2f 0b 2f 0a 24 6d  |em ID.NU.././.$m|
....
can i create a goo.o using gcc, which i can use with sas/c to build the final binary?

Last edited by emufan; 22 July 2017 at 14:29.
emufan is offline  
Old 22 July 2017, 16:03   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
AROS 68k comes with a utility called elf2hunk that converts GCC/AROS native binaries to Amiga/Hunk binaries. There should be a similar converter in the GCC BinUtils that imports Hunk objects or linker libraries to ELF format. I think it is called Lib2A or something like that.
Samurai_Crow is online now  
Old 22 July 2017, 17:28   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by emufan View Post
Code:
$ m68k-amigaos-g++.exe -g goo.cc -m68020 -m68881 -noixemul -ISDK/include slib4.o -o goo.p
hunk_drelx not supported yet
hunk_drelx not supported yet
hunk_drel16 not supported yet
hunk_drel16 not supported yet
HUNK_DREL16 usually exists for 16-bit base-relative addressing modes, accessing symbols from a Small Data section. On SAS/C, and other Amiga compilers like vbcc etc., these data- and bss-sections with the name "__MERGED" are automatically merged by the linker to form one big small data section, with all uninitialized sections at the end.

You cannot convert this object into anything else when your compiler or linker does not support small data in the same manner. You also need a startup code which sets up A4 with the base address. The linker has to provide _LinkerDB for the base, etc..

Only solution would be to recompile slib4 with gcc, but without small data mode.

Quote:
i tried to use the goo.o object file on the amiga with sas/c to link it with sc/slink, but the object file is not recognized
Code:
0000  00 02 01 07 00 00 2a 9c  00 00 01 0c 00 00 00 18  |......*.........|
This is a.out object file format (Unix), while most Amiga compilers only support the native hunk format.

Quote:
can i create a goo.o using gcc, which i can use with sas/c to build the final binary?
There may have been Amiga gcc-ports which can output hunk format object files. But I don't remember which. Usually older gcc ports have been more compatible...

Or try to convert the a.out object with vlink. For example (untested):
Code:
vlink -bamigahunk -r -o goo_hunk.o goo.o
phx is offline  
Old 22 July 2017, 17:42   #4
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
thanks for all the info.

elf2hunk/Lib2A i cannot find in my gcc 2.95.3/6.3.x builds.
vlink is more promissing, but fails:
Code:
$ /opt/m68k-amigaos6/bin/vlink -bamigahunk -r -o goo_hunk.o goo.o
vlink V0.16 (c)1997-2017 by Frank Wille

INTERNAL ERROR: aout_symbols(): Symbol ___CTOR_LIST__ in goo.o has type 22,
which is currently not supported.
Aborting.
do you want the goo.o to have a look?

Quote:
Originally Posted by phx View Post
There may have been Amiga gcc-ports which can output hunk format object files. But I don't remember which. Usually older gcc ports have been more compatible...
so there might be a m68k-amigaos-g++.exe option to write hunks instead of a.out format in the object files?
emufan is offline  
Old 22 July 2017, 22:23   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by emufan View Post
do you want the goo.o to have a look?
That's not necessary. Type 22 means it is a "set element" symbol. From /usr/include/nlist.h:
Code:
#define N_SETT  0x16            /* text set element symbol */
These "sets" are only used in a.out object files (for example to collect constructor function pointers), and there is no equivalent symbol type in hunk format anyway.

Quote:
so there might be a m68k-amigaos-g++.exe option to write hunks instead of a.out format in the object files?
I'm not sure. There may have been a 2.95.x port for AmigaOS many years ago (ADE or Geek Gadgets?) which generated hunk-format instead of a.out objects. No option needed in this case.

But I doubt such a feature ever existed as a cross-compiler under Linux or Windows.
phx is offline  
Old 22 July 2017, 23:48   #6
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by phx View Post
I'm not sure. There may have been a 2.95.x port for AmigaOS many years ago (ADE or Geek Gadgets?) which generated hunk-format instead of a.out objects. No option needed in this case.
The Geek Gadgets Amiga "unofficial" GCC 2.95.3 and GCC 3.4.0 output Amiga hunk format. There are people experimenting with using later versions of GCC with vlink to generate Amiga hunk format as well.

http://eab.abime.net/showthread.php?t=85474
matthey is offline  
Old 23 July 2017, 00:32   #7
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
i tested a copy of GG lite 1.0, building the hello.c program,
the object file only (gcc -c ...) but it was the same a.out format,
which i already got with the cygwin cross compiler.
I have to find another version.

well, the purpose of all of this, was to create a plugin for lightwave,
which was solved by alkis by fixing the source code.

thanks for all help.
emufan is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with SAS/C 6.55 update TheDarkCoder Coders. General 36 11 June 2021 12:17
GLX-related compilation problem with FS-UAE on Gentoo / GCC 4.8 yoshi314 support.FS-UAE 9 17 December 2013 19:49
(Useless benchmark) Dhrystone on Sas C/Gcc/Vbcc alkis Coders. System 3 16 October 2013 13:03
Problem with the SAS/C editor Leandro Jardim Coders. Language 0 17 August 2012 08:46

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13007 seconds with 13 queries