This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linking with target Z80


Op woensdag 30 september 2009, schreef Chris Smith:
> I'm having trouble using ld to link assembled Z80 files.
>
> Attached is a small test suite which assembles and links two
> files into a static library, and a third file which it assembles
> and tries to link to the library.
>
> At the moment it wont link. I have even tried supplying the three
> .o's with ld, instead of the lib, and that fails too. I'm looking
> to get a z80-coff format out, so I can use objdump/objcopy to get
> what I need.
>
> I think I may have got this to almost work once, but it linked
> the entire library and not the bits it required, wasting precious
> space. I don't know how I did it though.
>
> I'm not new to binutils, which is why I'm going crazy ;-)
>
> Am I approaching this incorrectly, or is z80-ld borked?
>
> Many thanks.
> Chris

Hello Chris,

Your test case fails because z80-as treats labels in assembly as 
local symbols by default. To make a symbol available for use in 
other files you must explicitly make it global with the .global 
directive as in the attached patch for your test case.

Kind regards,
Arnold
diff -up z80ldtest.orig/libfile1.z8s z80ldtest/libfile1.z8s
--- z80ldtest.orig/libfile1.z8s 2009-09-29 13:16:54.000000000 +0200
+++ z80ldtest/libfile1.z8s      2009-10-03 21:59:16.000000000 +0200
@@ -4,3 +4,4 @@ message1:
       rst   8
       defb  "lib file 1"
       ret
+.global message1
diff -up z80ldtest.orig/libfile2.z8s z80ldtest/libfile2.z8s
--- z80ldtest.orig/libfile2.z8s 2009-09-29 13:17:00.000000000 +0200
+++ z80ldtest/libfile2.z8s      2009-10-03 21:34:50.000000000 +0200
@@ -1,5 +1,6 @@
 .section .data

+.global message2
 message2:
       rst   8
       defb  "lib file 2"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]