Page MenuHomeFreeBSD

Simplify the RISC-V kernel linker invocation
ClosedPublic

Authored by mhorne on May 19 2020, 1:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 11 2024, 6:26 PM
Unknown Object (File)
Jan 24 2024, 9:23 PM
Unknown Object (File)
Jan 15 2024, 5:40 PM
Unknown Object (File)
Dec 22 2023, 11:55 PM
Unknown Object (File)
Nov 7 2023, 3:14 PM
Unknown Object (File)
Oct 19 2023, 5:47 PM
Unknown Object (File)
Sep 6 2023, 2:25 PM
Unknown Object (File)
Sep 6 2023, 8:17 AM
Subscribers

Details

Summary

Remove our custom SYSTEM_LD definition. This generates program headers
that are more consistent with other architectures, and more importantly,
are in line with what loader(8) expects when loading a kernel.

As noted in https://reviews.freebsd.org/D22920, there is no apparent
reason why the kernel would need a writable text segment, so removal of
the -N flag isn't likely to cause issue.

Test Plan

Compilation succeeds with clang and GCC.

Program header layout before:

Entry point 0xffffffc000000000
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flg    Align
  LOAD           0x0000000000001000 0xffffffc000000000 0x0000000080200000
                 0x0000000000751108 0x00000000008706d8  RWE    0x1000
  DYNAMIC        0x0000000000712690 0xffffffc000711690 0x0000000080911690
                 0x00000000000000c0 0x00000000000000c0  RW     0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0
  NOTE           0x0000000000685898 0xffffffc000684898 0x0000000080884898
                 0x0000000000000024 0x0000000000000024  R      0x4

And after:

Entry point 0xffffffc000000000
There are 8 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flg    Align
  INTERP         0x00000000005f0270 0xffffffc0005ef270 0x00000000807ef270
                 0x000000000000000d 0x000000000000000d  R      0x1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000001000 0xffffffc000000000 0x0000000080200000
                 0x000000000068418c 0x000000000068418c  R E    0x1000
  LOAD           0x0000000000686000 0xffffffc000686000 0x0000000080886000
                 0x00000000000ca718 0x00000000000ca718  RW     0x1000
  LOAD           0x0000000000750718 0xffffffc000750718 0x0000000080950718
                 0x000000000000095d 0x000000000011ff40  RW     0x1000
  DYNAMIC        0x0000000000747b78 0xffffffc000747b78 0x0000000080947b78
                 0x00000000000000c0 0x00000000000000c0  RW     0x8
  GNU_RELRO      0x0000000000744c00 0xffffffc000744c00 0x0000000080944c00
                 0x000000000000bb18 0x000000000000bb18  R      0x1
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0
  NOTE           0x0000000000685168 0xffffffc000684168 0x0000000080884168
                 0x0000000000000024 0x0000000000000024  R      0x4

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 31169
Build 28832: arc lint + arc unit

Event Timeline

mhorne created this revision.
kp added a subscriber: kp.

Works for me (as in: I've tested this in my setup, and this works just fine).

This revision is now accepted and ready to land.May 19 2020, 4:50 PM

This should be fine for QEMU. @jrtc27 will this work for our FPGAs?

Yeah they don't need anything special, other than the ability to override KERNEL_LMA, which is kept here.

br added a subscriber: br.

Looks good

This revision was automatically updated to reflect the committed changes.