-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for binutils >= 2.36 #155
base: master
Are you sure you want to change the base?
Conversation
Thanks a lot! However I don’t know what happened. What should I do to understand the differences? |
It looks like the ELF loader is assuming that this section is not present, from binutils 2.36 on it gets added by default which causes the system to fail to be able to correctly load userland binaries. The solution is to simply remove the section altogether. Of course an alternative might be to adjust the loader code. I left this PR here not only in case a maintainer (though I realise the x86 version is no longer maintained) decided to merge but more so that somebody else who found xv6 broken could use this PR to fix things locally :) |
Yeah! I encounter the problem today when I compile this project in my Arch-Linux with binutils 2.36.1-3. |
arch is the key motivator for this change as it is the distro I use. If you try this it should sort out the issue. |
Yes!Thanks a lot again! Actually the version which I compiled is the rev9. Today I compile it with "make qemu-nox" in the arch-linux rather than the ubuntu 18.04 which I used to use. I deleted the "Werror" in CFLAGS to deal with the "-Werror=stringop-overflow=". Then it compiles well. However it hang over in the "Booting From Hard Disk“. After I revising the Makefile according to your's file and the #115.,it works well! |
Thanks for the PR. I fetched from your branch to make it work on Arch Linux. :) |
Thank You!!! hopefully they merge this PR soon! |
implemented mit-pdos#155 thank you to @lorenzo-stoakes
1) binutils>=2.36 mit-pdos#155 2) -Wstringop-overflow error in usertests.c Add: 1) .clangd
- add devcontainer config - fix boot process (ref: mit-pdos#155)
I think I understand why this is necessary. First, a small isolated testcase: void start() {
return;
}
CFLAGS = -m32 -march=i386
LDFLAGS = -m elf_i386
initcode: initcode.o
$(LD) $(LDFLAGS) -N -e start -o $@ $<
initcode.o: initcode.c
$(CC) $(CFLAGS) -c $< In this case where we leave the addresses as their defaults, we can see that
The sections start around When we do specify the address of the
Then, because of that far-out section, when we convert the initcode to a binary, rather than getting a nice and small 44 (!) byte binary, we get a 16+ MiB binary which would take ages for the ELF loader to load from the image. To get an idea of how long it takes, I modified the bootloader to output progress over serial, and the answer is long. Understanding this, let's explore our options for how to fix it. Deleting the Unfortunately, the I think that the cleanest solution is to write a super small linker script that fixes
...
initcode: initcode.S
$(CC) $(CFLAGS) -nostdinc -I. -c initcode.S
$(LD) $(LDFLAGS) -T initcode.ld -o initcode -N initcode.o
$(OBJDUMP) -S initcode.o > initcode.asm
...
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text : {
*(.text)
}
} |
As-is trying to build with binutils 2.36 and a recent gcc is problematic in 2 ways:
This PR resolves both issues, firstly by stripping the newly introduced '.note.gnu.property' section introduced by binutils 2.36 which appears to be the source of the problem and secondly suppressing the -Wstringop-overflow warning in usertests.c.
The PR also strips some trailing space in the Makefile as trailing space is indeed, the devil.