LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2005, 04:11 PM   #1
B2T
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Rep: Reputation: 0
Question cannot link with ld


Hello

I can't link my .o files with ld, it sais "section .data overlaps section .text" and that there is not enough room for headers. Im using binutils 2.16.1.
The linker script I use:


Code:
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
  .text phys : AT(phys) {
    code = .;
    *(.text)
    . = ALIGN(4096);
  }
  .data : AT(phys + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(phys + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}
Most files are assembled by gcc 3.4.0, but one of them is produced by nasm 0.98.39.

Thx for your help
 
Old 10-15-2005, 05:38 PM   #2
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Is there some reason you're using ld? You generally don't need to use ld directly. What happens if you try to link them with gcc?
 
Old 10-15-2005, 05:57 PM   #3
B2T
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Original Poster
Rep: Reputation: 0
It is because gcc can't produce flat binaries. (or can it?)
 
Old 10-15-2005, 10:27 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
I'm curious: what's a "flat binary"?

I've never, *ever* had a occasion to write an "ld" parameter script like you're doing.

I'm not saying it's wrong - but I am curious: "Why???"

Thanx in advance .. PSM

PS:
What environment is this for? Straight Linux? Some kind of embedded environment?

Last edited by paulsm4; 10-15-2005 at 10:28 PM.
 
Old 10-16-2005, 03:37 AM   #5
B2T
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Original Poster
Rep: Reputation: 0
flat binary is a kind of executable format with very little overhead, they are lightweight and contain only little code beside the code that you wrote. Out of curiosity, I only want to tackle around in programming without an operating system (altough i do not want to make one). As a starting point however, I've found a nice tutorial at http://www.osdever.net/bkerndev/index.php?the_id=90 (that's where I got the script from). It is the best to use such kind of binaries as they can be loaded directly by the BIOS, it might be possible however that i dont need it as my programme is loeded by grub, which might be able to load other file formats as well. But if i stick with this format, all i need to do if i decide i want my own verysimple boot loader, is to write some asm to switch to protected mode. Note that im currently experimenting in this area and am not an expert or something like that.

Last edited by B2T; 10-16-2005 at 04:51 AM.
 
Old 10-16-2005, 05:48 AM   #6
B2T
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Header error solved by not using the cross-compiled ld, but the original one in the cygwin download.

But what in my code could cause overlapping sections? This problem is still present.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Broadcom BCM4401 NIC: Link is Down, Link is up mr.wobble Linux - Hardware 6 08-31-2007 10:48 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 06:30 AM
OpenBSD 3.6 install D-Link 300T / D-Link DFE 528TX lesleyb *BSD 2 04-01-2005 06:29 PM
Wake on Lan - Link on b4 power up, No Link light after shutdown? Mark007 Linux - Networking 0 11-20-2004 08:16 PM
eth1... failed; no link present. Check Link? illegalien Linux - Networking 3 11-03-2002 10:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration