[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Question on BIGGEST_ALIGNMENT in GCC on NetBSD/m68k



On Thu, Jun 05, 2025 at 10:49:08AM +0200, Anders Magnusson wrote:
> Just curious; does not Linux use the processor-specific flagging in the
> binary that can tell whether it's 16- or 32-bit-aligned (and handle it
> thereafter)?
> 
> NetBSD changed VAX from 1k to 4k pages quite some time ago, and to be able
> to use both we added a new id for 4k pages.

Or add an ELF note to all new binaries - we do that on sparc64 to mark
the compiler memory model used and give all binaries w/o the note
(or a note that it is using "medlow") a different VA memory layout (to
keep shared libs in range of the instructions used there, but defeating
most of ASLR).

Example:

 > file ls  
ls: ELF 64-bit MSB pie executable, SPARC V9, relaxed memory ordering, version 1 (SYSV), dynamically linked, interpreter /libexec/ld.elf_so, for NetBSD 10.99.14, compiler model: medmid, not stripped

 > readelf -n ls

Displaying notes found in: .note.netbsd.ident
  Owner                Data size        Description
  NetBSD                0x00000004      IDENT 1099001400 (10.99.14)

Displaying notes found in: .note.netbsd.pax
  Owner                Data size        Description
  NetBSD                0x00000004      PaX <>

Displaying notes found in: .note.netbsd.mcmodel
  Owner                Data size        Description
  NetBSD        0x00000008      Unknown note type: (0x00000006)


The kernel finds these at exec/load time and sets a flag in the process
structure, and the (very few) places where it is important test for it.

This makes old installations compatible and old binaries using old
shared libs too, but you still can not mix shared libs (so you may have
to bump libc major if you really want to keep everything compatible).

Martin


Reply to: