OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jul 06, 2022 5:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Following the OS Specific Toolchain Tutorial
PostPosted: Mon Nov 19, 2007 9:07 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Hi,

I have just been following the [wiki]OS Specific Toolchain[/wiki] tutorial in the wiki, which appears to be very well writen. I am just having a slight problem trying to switch to an x86_64 target for binutils (specifically LD). Configure works fine, but when running make in cygwin, I get the following error:

Code:
ecaracal_x86_64.o: In function `gldcaracal_x86_64_after_parse':
/usr/src/build-binutils/ld/../../binutils-2.18/ld/emultempl/ia64elf.em:37: undef
ined reference to `_bfd_elf64_ia64_after_parse'
collect2: ld returned 1 exit status


I guess this is a problem with me converting the i586 target to x86_64, and the problem probably resides somewhere in the 'Edit configure.tgt' or 'Edit Makefile.in' steps.

Does anyone know where I should look to see what I did wrong? Oh - by the way, I have successfully cross-compiled a plain x86_64 binutils and gcc using the same installation of Cygwin (I just wanted my own toolchain which can be customised further in the future).

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 19, 2007 1:11 pm 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
What line did you add to ld/Makefile.in? It looks like you're trying to reference the IA64 script rather than the x86_64 one?

Regards,
John.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 19, 2007 2:47 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3881
Location: Eindhoven
did you enable 64-bit-bfd?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 2:59 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Hi,

jnc100 wrote:
What line did you add to ld/Makefile.in? It looks like you're trying to reference the IA64 script rather than the x86_64 one?


Code:
eelf_x86_64.c: $(srcdir)/emulparams/elf_x86_64.sh \
  $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
   ${GENSCRIPTS} elf_x86_64 "$(tdir_elf_x86_64)"
ecaracal_x86_64.c: $(srcdir)/emulparams/caracal_x86_64.sh \
  $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} caracal_x86_64 "$(tdir_caracal_x86_64)"


Just included the x86_64 elf entry as well, as this is what I have been using up to now and that seems to have worked.

Candy wrote:
did you enable 64-bit-bfd?


Yes - not the first time I compiled, but the second time, I emptied the build-binutils folder and used:
Code:
../binutils-2.18/configure --target=$TARGET --prefix=$PREFIX --enable-64-bit-bfd

As it is a new day, I am going over all the steps of the tutorial again to ensure I didn't miss anything. I'll let you know if it works. I'll also make sure that anything I altered contains x86_64 rather than IA64, so thanks for that hint.

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 4:01 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Nope - same error. I am going to have a play with the compiler and perhaps follow the tutorial using the i586-elf target to get more familiar with it before trying to be a smart arse and adapt the tutorial to x86_64.

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 4:44 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Quote:
/usr/src/build-binutils/ld/../../binutils-2.18/ld/emultempl/ia64elf.em:37: undef
ined reference to `_bfd_elf64_ia64_after_parse'


That is seriously wrong. There is some Itanium stuff (IA64) being compiled in. Did you in one place accidentally write ia64 instead of x86_64? Remember that for Intel IA32 is x86, IA64 is Itanium. (And a heap of junk it is too!)

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 5:12 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Ok - my transposition mistake from i[3-7]86 to x86_64. I have just replaced binutils-2.18 with a freshly downloaded version to undo all of my changes and am giving it a go from scratch. Chances are I copied something from another section of a file and adapted it to my cross compiler entry. I must have copied from an IA64 rather than x86_64 target. I'll obviously be a bit more cautious this time!

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 6:33 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
I have just successfully completed the tutorial for GCC and Binutils for the i586 version of the compiler by following the tutorial to the letter. I can't emphasise this enough - if you miss something, you generally don't find out until 20 minutes in to the compilation #-o .

I'm going to write down what I do with the conversion to x86_64 now and if it all works will post the changes I had to make.

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 5:17 pm 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
I've just tested targeting a x86_64 target and following the instructions on the wiki seems to work (it appears --enable-64-bit-bfd isn't actually required to produce a libbfd that can handle elf64, at least in binutils 2.18). You obviously need to make the necessary changes. Some important ones to note are:

1) bfd/config.bfd: targ_defvec=bfd_elf64_x86_64-vec
targ_selvecs="bfd_elf32_i386_vec i386coff_vec"
want64=true
;;

2) gas/configure.tgt: should still have case statement for i386-*-myos* (rather than x86_64) as the variable generic_target is formed from the variable cpu_type, where cpu_type is i386 for i[3-7]86 and x86_64 (defined further up the file)

3) ld/configure.tgt: targ_emul=myos_x86_64
You can also add targ_extra_emuls=myos_i386 if you like

4) define the emulation(s) as usual. I used elf_x86_64.sh as an emulparams template to base the specific one on. Add to Makefile.in as usual, watch those spaces/tabs and curly/round brackets.

Thanks for trying out the tutorial. Please let me know how you got on.

Regards,
John.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 2:48 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
jnc100 wrote:
2) gas/configure.tgt: should still have case statement for i386-*-myos* .


Dammit - I knew it was me doing somthing wrong - the actual tutorial is very good, though. I'll just have another go now. Although I am very familiar with the toolchain from the build, link, assemble and objdump point of view, all this automatic configuration stuff is Greek to me at the moment :? .

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 3:32 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
jnc100 wrote:
1) bfd/config.bfd: targ_defvec=bfd_elf64_x86_64-vec


For anyone following this, this should read targ_defvec=bfd_elf64_x86_64_vec (note the last underscore) :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 4:26 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Thanks, John - I now have a working binutils and am about to apply the same theory to gcc. The only line I *know* I had wrong the first time was that gas/configure.tgt, which is odd seeing as the build always failed at the point of configuring ld. All that matters now is that it worked, though!

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 8:09 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Ok - at the risk of appearing to like talking to myself (4 messages in a row :-# ), I'll give a progress report. Using GCC 4.2.2 and Binutils 2.18, I have now successfully build toolchains for my OS. I have tried i586-pc-caracal and x86_64-pc-caracal (someone previously pointed out the -m32 switch, but I wanted separate chains for a different project anyway) and both worked very nicely.

If anyone else is doing the same and it doesn't work first time, my advice is to read the error messages carefully and persist, because it does work.

Just a thought - how about a grid with tested versions of the compiler and binutils, a la [wiki]GCC Cross-Compiler[/wiki]? I could add this to the article, or leave it to jnc100, if you like.

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 10:38 am 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
AJ wrote:
I have now successfully build toolchains for my OS

Good to hear it. Once again, thanks for testing the tutorial.

AJ wrote:
Using GCC 4.2.2 and Binutils 2.18

I wrote it for 4.2.1/2.18, so that's another setup to put a tick by.

AJ wrote:
how about a grid with tested versions of the compiler and binutils

Be my guest, if you think its necessary. Personally, I'd be more interested in something showing success with various combinations of gcc/binutils, processor, object type, whether an existing emulation was simply copied or a new one written from scratch (emultempl + scripttempl also), additions to the newlib scripts and things like that.

Regards,
John.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 10:45 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
OK - I'll add the versions I have used to the discussion page for your wiki article. If we get enough people trying various things like that, perhaps we can then decide how to lay out a success/failure grid of some sort.

Cheers,
Adam


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 12 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 © 2000, 2002, 2005, 2007 phpBB Group