Git Product home page Git Product logo

Comments (12)

mintsuki avatar mintsuki commented on May 26, 2024

I cannot reproduce this. Are you sure all the header tags have been properly linked to each other?

from limine.

ethindp avatar ethindp commented on May 26, 2024

I think so... Here are my tag structures:

#[repr(C, align(4))]
struct Stack([u8; MAX_STACK_SIZE]);
static STACK: Stack = Stack([0; MAX_STACK_SIZE]);

// Tags
static VIDEO_TAG: StivaleAnyVideoTag = StivaleAnyVideoTag::new()
    .preference(0)
    .next(&FB_TAG as *const StivaleFramebufferHeaderTag as *const ());
static FB_TAG: StivaleFramebufferHeaderTag = StivaleFramebufferHeaderTag::new()
    .framebuffer_bpp(32)
    .next(&TERMINAL_TAG as *const StivaleTerminalHeaderTag as *const ());
static TERMINAL_TAG: StivaleTerminalHeaderTag =
    StivaleTerminalHeaderTag::new().next(&SMP_TAG as *const StivaleSmpHeaderTag as *const ());
static SMP_TAG: StivaleSmpHeaderTag = StivaleSmpHeaderTag::new()
    .flags(StivaleSmpHeaderTagFlags::X2APIC)
    .next(&LVL5_PG_TAG as *const Stivale5LevelPagingHeaderTag as *const ());
static LVL5_PG_TAG: Stivale5LevelPagingHeaderTag = Stivale5LevelPagingHeaderTag::new()
    .next(&UNMAP_NULL_TAG as *const StivaleUnmapNullHeaderTag as *const ());
static UNMAP_NULL_TAG: StivaleUnmapNullHeaderTag = StivaleUnmapNullHeaderTag::new();

#[link_section = ".stivale2hdr"]
#[used]
static BOOT_LOADER_HEADER: StivaleHeader = StivaleHeader::new()
    .stack(STACK.0.as_ptr_range().end)
    .flags((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4))
    .tags(&VIDEO_TAG as *const StivaleAnyVideoTag as *const ());

from limine.

mintsuki avatar mintsuki commented on May 26, 2024

Still cannot reproduce.

from limine.

ethindp avatar ethindp commented on May 26, 2024

I've attached my kernel binary; I'm not sure what other information I can give you. The only thing I did to cause this error was upgrading Limine.
kernel.gz

from limine.

mintsuki avatar mintsuki commented on May 26, 2024

Limine cannot find any tag, apparently. Are you setting the tag IDs correctly?

from limine.

ethindp avatar ethindp commented on May 26, 2024

Yeah... It was working fine before I updated to 2.88...

from limine.

mintsuki avatar mintsuki commented on May 26, 2024

Try adding a PT_DYNAMIC PHDR to your linker script. See the linker script at https://github.com/stivale/stivale2-barebones.

This should've already been present in your linker script. Limine prior to 2.88 used the section table in order to find the .dynamic section but this is in violation of the ELF specification and was thus changed. Kernels which were properly linked prior to this change will experience no difference, but your kernel lacks a PT_DYNAMIC PHDR, so it breaks.

from limine.

ethindp avatar ethindp commented on May 26, 2024

I'm not quite sure why this is the case. My linker script is:

OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)

ENTRY(_start)

/* Define the program headers we want so the bootloader gives us the right */
/* MMU permissions */
PHDRS
{
    null    PT_NULL    FLAGS(0);
    text    PT_LOAD    FLAGS(0x5);
    rodata  PT_LOAD    FLAGS(0x4);
    data    PT_LOAD    FLAGS(0x6);
}

SECTIONS
{
    /* We wanna be placed in the topmost 2GiB of the address space, for optimizations */
    /* and because that is what the stivale2 spec mandates. */
    . = 0xffffffff80000000;

    .text : {
        *(.text .text.*)
    } :text

    /* Move to the next memory page for .rodata */
    . += CONSTANT(MAXPAGESIZE);

    /* We place the .stivale2hdr section containing the header in its own section, */
    /* and we use the KEEP directive on it to make sure it doesn't get discarded. */
    .stivale2hdr : {
        KEEP(*(.stivale2hdr))
    } :rodata

    .rodata : {
        *(.rodata .rodata.*)
    } :rodata

    /* Move to the next memory page for .data */
    . += CONSTANT(MAXPAGESIZE);

    .data : {
        *(.data .data.*)
    } :data

    .bss : {
        *(COMMON)
        *(.bss .bss.*)
    } :data
}

And that looks nearly identical to the one you linked to. I'm compiling with Rusts x86_64-unknown-none target and giving it my linker script as an extra argument.

from limine.

mintsuki avatar mintsuki commented on May 26, 2024

Your compiler is generating a shared object (it should really be a static-PIE, but this doesn't matter here).

I forgot that the barebones does not have the dynamic stuff in it anymore, but basically what you need is to add a:

dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)) ;

line to your PHDRS block (at the end, after data, will suffice).
Then you need to place the .dynamic section inside that PHDR by adding:

.dynamic : {
    *(.dynamic)
} :data :dynamic

between your .data and .bss sections.

Alternatively, you can leave your script as is and convince your compiler to make a non-relocatable ELF.

from limine.

Andy-Python-Programmer avatar Andy-Python-Programmer commented on May 26, 2024

@ethindp try and use this target json file instead of using the x86_64-unknown-none target:

{
  "arch": "x86_64",
  "code-model": "kernel",
  "cpu": "x86-64",
  "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
  "disable-redzone": true,
  "executables": true,
  "features": "-mmx,-sse,+soft-float",
  "has-rpath": false,
  "has-thread-local": false,
  "linker-flavor": "ld.lld",
  "linker": "ld.lld",
  "llvm-target": "x86_64-unknown-none",
  "max-atomic-width": 64,
  "os": "none",
  "panic-strategy": "abort",
  "pre-link-args": {
    "ld.lld": [
      "-z",
      "max-page-size=0x1000",
      "-T",
      "kernel/x86_64-bare.ld"
    ]
  },
  "stack-probes": {
    "kind": "call"
  },
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-pointer-width": "64"
}

from limine.

ethindp avatar ethindp commented on May 26, 2024

Thanks, that worked!

from limine.

ethindp avatar ethindp commented on May 26, 2024

I should clarify: the linker script modification worked. I don't mind using a built-in rust target TBH.

from limine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.