Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-07

Getting fpc to work on Solaris (11)

18 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

Hi all,

I'm trying to set-up a VM with Solaris (x86_64).

Problem is that fpc refuses to link applications. It complains that there is a syntax error in the build-in linker scripts. How that's possible, I don't know.

When I use -T, so that the default linker scripts are not used, linking goes well, but the application terminates immediately: 'Bad entry point'. That's probably because the link.res link-script is missing too much info to be used without the default linker-scripts.

Does this ring a bell to anyone? And maybe someone know where I can find the default-linker scripts?

Joost.

Reply by email

Mark Morgan Lloyd
to Joost van der Sluis
Joost van der Sluis wrote 15 lines
Hi all, I'm trying to set-up a VM with Solaris (x86_64). Problem is that fpc refuses to link applications. It complains that there is a syntax error in the build-in linker scripts. How that's possible, I don't know. When I use -T, so that the default linker scripts are not used, linking goes well, but the application terminates immediately: 'Bad entry point'. That's probably because the link.res link-script is missing too much info to be used without the default linker-scripts. Does this ring a bell to anyone? And maybe someone know where I can find the default-linker scripts?

Which version of the compiler? I didn't see this on SPARC but I think the first thing I'd check would be which linker (ld) was actually being used- I had to do a lot of tweaking to get paths right.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Ludo Brands
to Joost van der Sluis: I'm trying to set-up a VM with Solaris (x86_64). Problem is that fpc refuses to link…

You need to get the gnu binutils from sunfreeware.com and set your path to include /usr/local/bin.
If you want to build the compiler you'll also need the gnu make from the same source.

Ludo

Show quoted text 35 lines
-----Message d'origine----- De : De la part de Joost van der Sluis Envoyé : lundi 11 juillet 2011 15:06 À : FPC developers' list Objet : [fpc-devel] Getting fpc to work on Solaris (11) Hi all, I'm trying to set-up a VM with Solaris (x86_64). Problem is that fpc refuses to link applications. It complains that there is a syntax error in the build-in linker scripts. How that's possible, I don't know. When I use -T, so that the default linker scripts are not used, linking goes well, but the application terminates immediately: 'Bad entry point'. That's probably because the link.res link-script is missing too much info to be used without the default linker-scripts. Does this ring a bell to anyone? And maybe someone know where I can find the default-linker scripts? Joost. -- My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Joost van der Sluis
to Ludo Brands
Ludo Brands wrote
You need to get the gnu binutils from sunfreeware.com and set your path to include /usr/local/bin.

I have them installed. (Well, using 'pkg install gnu-binutils') Or else gld wouldn't be there is no '/usr/local/bin'?

Do you think I can better try the binutils at the sunfreeware website?

If you want to build the compiler you'll also need the gnu make from the same source.

To my surprise was 'gmake' installed by default.

Joost.

Reply by email

Ludo Brands
to Joost van der Sluis
Show quoted text 9 lines
> You need to get the gnu binutils from sunfreeware.com and set your > path to include /usr/local/bin. I have them installed. (Well, using 'pkg install gnu-binutils') Or else gld wouldn't be there is no '/usr/local/bin'? Do you think I can better try the binutils at the sunfreeware website?

I replied a little bit too quick. You're using solaris 11 and sunfreeware.com supports up to solaris 10.

When you write "When I use -T", I guess that is -st ? What command line did you use to link with link.res?

Ludo

Reply by email

Joost van der Sluis
to Ludo Brands
Ludo Brands wrote 15 lines
> > You need to get the gnu binutils from sunfreeware.com and set your > > path to include /usr/local/bin. > > I have them installed. (Well, using 'pkg install > gnu-binutils') Or else gld wouldn't be > there is no '/usr/local/bin'? > > Do you think I can better try the binutils at the sunfreeware website? > I replied a little bit too quick. You're using solaris 11 and sunfreeware.com supports up to solaris 10. When you write "When I use -T", I guess that is -st ? What command line did you use to link with link.res?

Application name is test. (It's a hello world)

/usr/bin/gld -s -L. -o test link.res
result:
/usr/bin/gld:built in linker script:21: syntax error

When I use this: (-T, not -st)
/usr/bin/gld -s -L. -o test -T link.res
result: link succeed, but running:
./test
test: Bad entry point
Killed

Joost.

Reply by email

Ludo Brands
to Joost van der Sluis
Show quoted text 6 lines
Application name is test. (It's a hello world) /usr/bin/gld -s -L. -o test link.res result: /usr/bin/gld:built in linker script:21: syntax error

If you add --verbose it'll print out the internal ld script. See what line 21 corresponds with.

When I use this: (-T, not -st) /usr/bin/gld -s -L. -o test -T link.res

OK. I was thinking of the fpc option.

Ludo

Reply by email

Joost van der Sluis
to Ludo Brands
Ludo Brands wrote 9 lines
> Application name is test. (It's a hello world) > > /usr/bin/gld -s -L. -o test link.res > result: > /usr/bin/gld:built in linker script:21: syntax error > If you add --verbose it'll print out the internal ld script. See what line 21 corresponds with.

Tried that, but it shows nothing. (Apparently it parses the script first)

But what I did find out was that some of the scripts in /usr/gnu/i386-pc-solaris2.11/lib/ldscripts are incomplete! For example the file elf_i386.xcs is only 21 lines long. It looks like the effect in this bug-report:
http://lists.gnu.org/archive/html/bug-binutils/2010-04/msg00000.html

Only not all files are truncated, and on another offset. Any idea how to get the right scripts? (Can I force a re-install of the package? Or an older version)

> When I use this: (-T, not -st) > /usr/bin/gld -s -L. -o test -T link.res OK. I was thinking of the fpc option.

Oh, yes, sure. I was running the linker manually.

Joost

Reply by email

Joost van der Sluis
to Ludo Brands
Ludo Brands wrote 10 lines
> > If you add --verbose it'll print out the internal ld script. > See what line 21 corresponds with. > > I've attached the internal script for the gnu ld 2.21.1 on Solaris 10. Try /usr/bin/gld -s -L. -o test -T ld_internal_script link.res

At first it did not work. I've edited the file, changed the output-format in the script from 'elf32-i386-sol2' to 'elf32-i386' and now it works.

I'll use this script for now, thanks for the help. But I still wonder why it doesn't work by default...

Joost.

Reply by email

Mark Morgan Lloyd
to Joost van der Sluis: At first it did not work. I've edited the file, changed the output-format in the script…
Joost van der Sluis wrote 15 lines
On Mon, 2011-07-11 at 18:29 +0200, Ludo Brands wrote: >> If you add --verbose it'll print out the internal ld script. >> See what line 21 corresponds with. >> >> > I've attached the internal script for the gnu ld 2.21.1 on Solaris 10. > Try > /usr/bin/gld -s -L. -o test -T ld_internal_script link.res At first it did not work. I've edited the file, changed the output-format in the script from 'elf32-i386-sol2' to 'elf32-i386' and now it works. I'll use this script for now, thanks for the help. But I still wonder why it doesn't work by default...

Can't find any reference to a -sol2 suffix even looking at (SPARC) Solaris 8. For that matter I can't find it in the FPC sources, except very obtusely referring to a version of gcc. Has install put something suspect in fpc.cfg?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Joost van der Sluis
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 21 lines
Joost van der Sluis wrote: > On Mon, 2011-07-11 at 18:29 +0200, Ludo Brands wrote: >>> If you add --verbose it'll print out the internal ld script. >>> See what line 21 corresponds with. >>> >>> >> I've attached the internal script for the gnu ld 2.21.1 on Solaris 10. >> Try >> /usr/bin/gld -s -L. -o test -T ld_internal_script link.res > > At first it did not work. I've edited the file, changed the > output-format in the script from 'elf32-i386-sol2' to 'elf32-i386' and > now it works. > > I'll use this script for now, thanks for the help. But I still wonder > why it doesn't work by default... Can't find any reference to a -sol2 suffix even looking at (SPARC) Solaris 8. For that matter I can't find it in the FPC sources, except very obtusely referring to a version of gcc. Has install put something suspect in fpc.cfg?

It was in the linker-script that Ludo Brands send to this list.

Joost

Reply by email

Ludo Brands
to Mark Morgan Lloyd: Can't find any reference to a -sol2 suffix even looking at (SPARC) Solaris 8. For that…
Show quoted text 6 lines
Can't find any reference to a -sol2 suffix even looking at (SPARC) Solaris 8. For that matter I can't find it in the FPC sources, except very obtusely referring to a version of gcc. Has install put something suspect in fpc.cfg?

This is pure ld. Nothing to do with fpc. When ld is built for a platform it contains an internal script with basic build information (type of binary file to create, etc.) for that particular platform. This way the user can easily build the same software on different platforms without being bothered with platform specific settings. For Solaris 11 there seems to be a gnu ld around with wrong/corrupt internal scripts. The one I sent to Joost was the output I got on solaris 10 from a ld --verbose. If you try this command on your sparc machine, you'll probably see a lot of differences because of the different cpu.

Ludo

Reply by email

Mark Morgan Lloyd
to Ludo Brands
Ludo Brands wrote 17 lines
> Can't find any reference to a -sol2 suffix even looking at (SPARC) > Solaris 8. For that matter I can't find it in the FPC sources, except > very obtusely referring to a version of gcc. Has install put > something > suspect in fpc.cfg? > This is pure ld. Nothing to do with fpc. When ld is built for a platform it contains an internal script with basic build information (type of binary file to create, etc.) for that particular platform. This way the user can easily build the same software on different platforms without being bothered with platform specific settings. For Solaris 11 there seems to be a gnu ld around with wrong/corrupt internal scripts. The one I sent to Joost was the output I got on solaris 10 from a ld --verbose. If you try this command on your sparc machine, you'll probably see a lot of differences because of the different cpu.

If I understand you correctly, on SPARC Solaris 10 I see

GNU ld version 2.15
Supported emulations:
elf32_sparc
elf64_sparc
using internal linker script:
================================================== /* Script for -z combreloc: combine and sort reloc sections */ OUTPUT_FORMAT("elf32-sparc", "elf32-sparc",
"elf32-sparc")
OUTPUT_ARCH(sparc)

One thing I don't understand is whether there's any scope for the computer type that's optionally fed to binutils's ./configure to appear in the final programs (ld for Solaris etc.). I definitely see references to sol2 as the final part of this parameter in config.sub which I believe is used to check and parse the type, where it's used to specify that the OS is -solaris2 rather than -sysv etc.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Ludo Brands
to Mark Morgan Lloyd
Show quoted text 10 lines
One thing I don't understand is whether there's any scope for the computer type that's optionally fed to binutils's ./configure to appear in the final programs (ld for Solaris etc.). I definitely see references to sol2 as the final part of this parameter in config.sub which I believe is used to check and parse the type, where it's used to specify that the OS is -solaris2 rather than -sysv etc.

That is how cross binutils are made. On system x you do a configure --prefix=dir-to-put-tools
--host=the-host --target=the-target

The config.guess script is used by configure when you don't specify a target.

More usefull info here:
http://wiki.osdev.org/OS_Specific_Toolchain

Ludo

Reply by email

Mark Morgan Lloyd
to Ludo Brands
Ludo Brands wrote 20 lines
> One thing I don't understand is whether there's any scope for the > computer type that's optionally fed to binutils's ./configure > to appear > in the final programs (ld for Solaris etc.). I definitely see > references > to sol2 as the final part of this parameter in config.sub which I > believe is used to check and parse the type, where it's used > to specify > that the OS is -solaris2 rather than -sysv etc. > That is how cross binutils are made. On system x you do a configure --prefix=dir-to-put-tools --host=the-host --target=the-target The config.guess script is used by configure when you don't specify a target. More usefull info here: http://wiki.osdev.org/OS_Specific_Toolchain

Yes, but you can also do e.g.

$ ./configure --prefix=/usr/local/mipsel-linux mipsel-linux-gnu

and what I was wondering was whether the final portion of the parameter could, in some cases, "leak" into the binaries e.g. into ld's embedded script, resulting in the sort of problem that Joost reported:

>>>> At first it did not work. I've edited the file, changed the >>>> output-format in the script from 'elf32-i386-sol2' to 'elf32-i386' >>>> and now it works.
Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Ludo Brands
to Mark Morgan Lloyd
Show quoted text 15 lines
Yes, but you can also do e.g. $ ./configure --prefix=/usr/local/mipsel-linux mipsel-linux-gnu and what I was wondering was whether the final portion of the parameter could, in some cases, "leak" into the binaries e.g. into ld's embedded script, resulting in the sort of problem that Joost reported: >>>>> At first it did not work. I've edited the file, changed the >>>>> output-format in the script from 'elf32-i386-sol2' to 'elf32-i386' >>>>> and now it works.

I sent the solaris 10 default script to Joost to replace his corrupt/bugged internal ld script. elf32-i386-sol2 is the format used in solaris 10. Solaris 11 uses elf32-i386. That is why he had to edit the solaris 10 script to get a working binary from ld on 11. The ld -T option tells the linker to not use the internal script but the script provided. IIRC Joost installed the binutils binary package.

Ludo

Ludo

Reply by email