Sign in Join

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

Mailing lists / fpc-pascal / 2013-04

Mipsel compilation: changing elf flags?!

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd
to Reinier Olislagers
Reinier Olislagers wrote 8 lines
See this forum thread: http://lazarus.freepascal.org/index.php/topic,20664.msg119960.html#msg119960 Forum user ocye got mipsel binaries, but the ELF flags apparently need to be changed due to a bug in older Linux kernels. How can this be done? In addition, is there perhaps a compiler switch to manage this?

Interesting, there was somebody in (I think) fpc-devel a few months ago with similar problems but we all rather went in circles.

Since Lemote appears to be using the compiler OK and since I think I've had it running on (a Qemu emulation of) mipsel, I think that the problem is that /some/ kernel builds are expecting a particular ELF header on /some/ machine types. If OP could identify the correct parameter for ld it might be possible to use fpc's -k option.

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

Reinier Olislagers
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 18 lines
Reinier Olislagers wrote: > See this forum thread: > http://lazarus.freepascal.org/index.php/topic,20664.msg119960.html#msg119960 > > > Forum user ocye got mipsel binaries, but the ELF flags apparently need > to be changed due to a bug in older Linux kernels. > > How can this be done? > In addition, is there perhaps a compiler switch to manage this? Interesting, there was somebody in (I think) fpc-devel a few months ago with similar problems but we all rather went in circles. Since Lemote appears to be using the compiler OK and since I think I've had it running on (a Qemu emulation of) mipsel, I think that the problem is that /some/ kernel builds are expecting a particular ELF header on /some/ machine types.

Correct. The forum thread links to a thread re failing executables using gdd where it appears that (certain?) 2.4 and 2.6 kernels did *not* want the MIPS flag set.

If OP could identify the correct parameter for ld it might be possible to use fpc's -k option.

Ok, so we have to dig into ld. Thanks; will pass it on.

Thanks, Mark!

Reply by email

Mark Morgan Lloyd
to Reinier Olislagers
Reinier Olislagers wrote 21 lines
>> Forum user ocye got mipsel binaries, but the ELF flags apparently need >> to be changed due to a bug in older Linux kernels. >> >> How can this be done? >> In addition, is there perhaps a compiler switch to manage this? > Interesting, there was somebody in (I think) fpc-devel a few months ago > with similar problems but we all rather went in circles. > > Since Lemote appears to be using the compiler OK and since I think I've > had it running on (a Qemu emulation of) mipsel, I think that the problem > is that /some/ kernel builds are expecting a particular ELF header on > /some/ machine types. Correct. The forum thread links to a thread re failing executables using gdd where it appears that (certain?) 2.4 and 2.6 kernels did *not* want the MIPS flag set. > If OP could identify the correct parameter for ld > it might be possible to use fpc's -k option. > Ok, so we have to dig into ld. Thanks; will pass it on.

There might be something in
http://wiki.lazarus.freepascal.org/Native_MIPS_Systems that will help since it includes the command lines I used for the cross-compilers etc., finding out what variants of binutils could be built was the hardest part.

I was hoping to be able to test the MIPS etc. targets on a fairly regular basis, but Qemu (running on the systems available here) quite simply turned out to not be fast enough, and I'm struggling to find time to revisit getting an SGI system running for big-endian work.

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

Heiko Tietze
If OP could identify the correct parameter for ld it might be possible to use

fpc's -k option.
What am I supposed to do? ld has myriads of options. I don't set any intentional (/usr/local/bin/mipsel-linux-ld is just a softlink to .../mipsel/bin/ld)

RE: [fpc-devel] FPC for MIPS Pierre Free Pascal Tue, 15 Jan 2013 07:59:00 -0800 I updated ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/mipsel-linux/ ...

svn up (Revision 24313)

export PP=
make "OPT=-O- -g" -C compiler mipsel
sudo mv compiler/ppcmipsel /usr/lib/fpc/2.6.2/ppcmipsel {I don't want to corrupt my standard compiler}
export PP=/usr/lib/fpc/2.6.2/ppcmipsel
mv rtl/units/mipsel-linux/ /usr/lib/fpc/2.6.2/units/ ppcmipsel -vt bogus

|Configfile search: /home/tietze/.fpc.cfg
|Reading options from file /home/tietze/.fpc.cfg
|Path "/usr/lib/fpc/2.7.1/units/mipsel-linux/httpd22/" not found |Path "/usr/lib/fpc/2.7.1/units/mipsel-linux/" not found |Path "/usr/lib/fpc/2.7.1/units/mipsel-linux/*/" not found |Path "/usr/lib/fpc/2.7.1/units/mipsel-linux/rtl/" not found |Path "/usr/lib/fpc/2.6.2/units/mipsel-linux/*/" not found |Path "/usr/lib/fpc/2.6.2/units/mipsel-linux/rtl/" not found |Free Pascal Compiler version 2.7.1 [2013/04/23] for mipsel |Copyright (c) 1993-2013 by Florian Klaempfl and others |Path "/usr/lib/fpc/2.7.1/units/mipsel-linux/rtl/" not found |Searching file /lib/ld.so.1... not found
|Searching file /lib/ld-uClibc.so.0... not found
|Compiler: /usr/lib/fpc/2.6.2/ppcmipsel
|Target OS: Linux for MIPSEL
|Using executable path: /usr/lib/fpc/2.6.2/
|Using unit path: /usr/lib/fpc/2.6.2/units/mipsel-linux/ |Using unit path: /usr/lib/fpc/2.6.2/
|Using library path: /usr/local/mipsel/lib/
|Using library path: /usr/lib/fpc/2.6.2/units/mipsel-linux/ |Using library path: /usr/lib/fpc/2.6.2/
|Using object path: /usr/lib/fpc/2.6.2/units/mipsel-linux/ |Using object path: /usr/lib/fpc/2.6.2/
|Compiling bogus

ppcmipsel hello.pp
|Free Pascal Compiler version 2.7.1 [2013/04/23] for mipsel |Copyright (c) 1993-2013 by Florian Klaempfl and others |Target OS: Linux for MIPSEL
|Compiling hello.pp
|Assembling hello
|Linking hello
|/usr/local/bin/mipsel-linux-ld: warning: link.res contains output sections; did you forget -T?
|/usr/local/bin/mipsel-linux-ld: hello.o: warning: linking abicalls files with non-abicalls files
|/usr/local/bin/mipsel-linux-ld: /usr/lib/fpc/2.6.2/units/mipsel- linux/system.o: warning: linking abicalls files with non-abicalls files |3 lines compiled, 0.1 sec

more .fpc.cfg
|#ifdef cpumipsel
|-Xd
|-Fl/usr/local/mipsel/lib
|-Pmipsel
|-Cg
|-CfSOFT
|-Fu/usr/lib/fpc/2.6.2/units/$fpctarget
|-Fu/usr/lib/fpc/2.6.2/units/$fpctarget/*
|-Fu/usr/lib/fpc/2.6.2/units/$fpctarget/rtl
|#endif

readelf -h hello
|ELF Header:
| Magic: 7f 45 4c 46 01 01 01 00 01 00 00 00 00 00 00 00 | Class: ELF32
| Data: 2's complement, little endian | Version: 1 (current)
| OS/ABI: UNIX - System V | ABI Version: 1
| Type: EXEC (Executable file) | Machine: MIPS R3000
| Version: 0x1
| Entry point address: 0x401210
| Start of program headers: 52 (bytes into file) | Start of section headers: 41624 (bytes into file) | Flags: 0x50001005, noreorder, cpic, o32, mips32 | Size of this header: 52 (bytes)
| Size of program headers: 32 (bytes)
| Number of program headers: 3
| Size of section headers: 40 (bytes)
| Number of section headers: 9
| Section header string table index: 8

Execution still fails on the Fritz!Box.

PS: Please CC' me any reply; I dislike mailinglists ;-)

Reply by email