Recent

Author Topic: NetBSD ELF format v2  (Read 3292 times)

VK2FVAX

  • Newbie
  • Posts: 4
NetBSD ELF format v2
« on: July 12, 2022, 07:45:03 am »

G'day.

Noticed something odd with the ELF versions on my NetBSD desktop install. I have the following output:

        mirage:~/src$ ./test
        Test
        mirage:~/src$ ldd ./test
        ldd: ./test: invalid ELF class 2; expected 1


Seems a little odd. What's a Class 2 in this instance?

Interestingly the distro all seems to be built the same way:

        mirage:~/src$ file /opt/fpc-3.2.2-amd64/bin/fp
        /opt/fpc-3.2.2-amd64/bin/fp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for NetBSD, with debug_info, not stripped
        mirage:~/src$ ldd /opt/fpc-3.2.2-amd64/bin/fp
        ldd: /opt/fpc-3.2.2-amd64/bin/fp: invalid ELF class 2; expected 1

I'm running the latest stable 9.2.

        mirage:~/src$ uname -a
        NetBSD mirage.local.net 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
        mirage:~/src$     

Anyone have a clue why it's emitting v2 ELF's? How do you display the library dependencies with this?

/usr/bin/nm seems to dump the symbol table pretty well.

Any ideas welcome.

Regards,
Al.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: NetBSD ELF format v2
« Reply #1 on: July 12, 2022, 09:16:24 am »

If it is like FreeBSD, run elfdump -h   on a FPC and a distribution binary.

It is possible that NetBSD changed binary format, and the startup code hasn't changed yet.

In the sources, the startup files are at fpc/rtl/netbsd/x86_64.

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: NetBSD ELF format v2
« Reply #2 on: July 12, 2022, 09:24:21 am »
Seems a little odd. What's a Class 2 in this instance?
According to wiki an ELF class (e_ident[EI_CLASS]) of 1 means 32 bit and 2 means 64 bit.  So this means your environment is expecting a 32 bit exe and is complaining that it is 64 bit.

VK2FVAX

  • Newbie
  • Posts: 4
Re: NetBSD ELF format v2
« Reply #3 on: July 12, 2022, 09:55:34 am »
Hi Ccrause.

It's a pretty weird one. I wonder what was used to compile fpc-3.2.2 .. maybe the maintainer is running against the trunk with -CURRENT where it's possibly all class2 .. and us poor nuffies on the stable releases from last year are getting class 1 still?

Speculating. It's all very strange.

Going to go and look up "LSB pie executable" vs "LSB executable".

Thanks for the comment.

polluks

  • Newbie
  • Posts: 3
Re: NetBSD ELF format v2
« Reply #4 on: February 06, 2023, 03:30:20 pm »
NetBSD 9.1:
I get the same message for a Go binary, seems to be an ldd bug.

 

TinyPortal © 2005-2018