Giter Club home page Giter Club logo

Comments (8)

wom-bat avatar wom-bat commented on August 18, 2024

Which version of qemu are you using? When I follow the steps you took, using GCC 5 and qemu 2.8.95 I get the expected results.

from sel4-tutorials.

statusfailed avatar statusfailed commented on August 18, 2024

I'm using default packages on Ubuntu 16.10, which have versions:

  • QEMU: QEMU emulator version 2.6.1 (Debian 1:2.6.1+dfsg-0ubuntu5.4)
  • gcc: gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
  • arm-none-eabi-gcc: arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)

I'll try using a newer QEMU and report back

from sel4-tutorials.

statusfailed avatar statusfailed commented on August 18, 2024

I tried two versions of QEMU: the latest master branch from git, and 2.9.0. Neither worked.

Next, I tried upgrading Ubuntu to 17.04, because I had a problem building seL4test with ld 2.27 (the version shipping with Ubuntu 16.10)

I'm now running these versions:

  • QEMU emulator version 2.8.0
  • gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
  • GNU ld (GNU Binutils for Ubuntu) 2.28

Unfortunately this didn't help either, and I still get the same error message. I did try using the Virtualbox appliance however, and that worked as expected.

It seems unlikely that gcc/ld would produce code that QEMU can't run, so perhaps they are not producing the right kind of file.

Indeed, I did discover a difference in the output files, namely the kernel image produced by my box (not the .ova) is dynamically linked! I'm assuming this is very wrong.

For clarity, here's the output of file images/* for my box, and the test OVA:

My box:

hello-1-image-ia32-pc99: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
kernel-ia32-pc99:        ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, not stripped

Virtualbox appliance:

hello-1-image-ia32-pc99: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
kernel-ia32-pc99:        ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped

I'm guessing this has happened due to a change in the ld command line flags. I'm not sure how to fix this however - I would appreciate any tips!

I messed about with LDFLAGS in kernel/Makefile, but to no avail. I tried adding -Bstatic and changing -m,elf_i386 to -melf_i386 but neither worked.

I'm not sure how to tell GCC to static link the kernel ELF image, so I kinda guessed: I changed kernel/Makefile line 582 to add the -static flag. My version now reads:

$(Q)${CHANGED} $@ ${CC} ${LDFLAGS} -static -Wl,-T -Wl,linker.lds_pp \

Unfortunately, while my kernel image file now says "statically linked", it still gives the same error when I run it in QEMU.

Copying the kernel image from the virtual machine to my machine works, so it seems like it's only the kernel image that isn't building correctly (I can run the .ova-produced kernel image alongside the application code built on my machine)

Any thoughts on what I can try now?

from sel4-tutorials.

wom-bat avatar wom-bat commented on August 18, 2024

The problem appears to be gcc version 6 which is creating dynamically linked programs even when you request static ones.
I installed gcc 6 and got the same problem you're seeing. I'll see what can be done...

from sel4-tutorials.

wom-bat avatar wom-bat commented on August 18, 2024

Please try this patch.

project kernel/
diff --git a/Makefile b/Makefile
index 5e31f2cd..0deee694 100644
--- a/Makefile
+++ b/Makefile
@@ -389,7 +389,7 @@ WARNINGS = all error strict-prototypes missing-prototypes nested-externs \
 CFLAGS += --std=c99 -nostdlib -nostdinc -ffreestanding \
 	${WARNINGS:%=-W%} ${INCLUDES}
 CPPFLAGS += -nostdinc
-LDFLAGS += -nostdlib -nostdinc
+LDFLAGS += -nostdlib -nostdinc -static
 LDFLAGS += -Wl,--build-id=none
 ASFLAGS += ${INCLUDES}
 


project projects/tools/
diff --git a/common-tool/Makefile.flags b/common-tool/Makefile.flags
index 0ddb7ad..54aacbb 100644
--- a/common-tool/Makefile.flags
+++ b/common-tool/Makefile.flags
@@ -25,6 +25,9 @@ NK_ASFLAGS =
 NK_CCFLAGS =
 
 ldflags-y += $(call cc-ldoption, -Wl$(comma)--build-id=none)
+ldflags-y += $(call cc-ldoption, -Wl$(comma)--no-pie)
+
+ccflags-y += $(call cc-option, -fno-pie)
 
 ifeq ($(CONFIG_ARCH_X86),y)
 	ccflags-y += $(call cc-option,-fno-stack-protector)
diff --git a/common-tool/common.mk b/common-tool/common.mk
index 321bf1c..e17badc 100644
--- a/common-tool/common.mk
+++ b/common-tool/common.mk
@@ -113,8 +113,8 @@ ifeq (${CONFIG_USER_CFLAGS},)
 
     CFLAGS += $(NK_CFLAGS)
     CXXFLAGS += $(NK_CXXFLAGS)
-    CFLAGS += -fno-stack-protector
-    CXXFLAGS += -fno-stack-protector
+    CFLAGS += -fno-stack-protector $(call cc-option,-fno-pie)
+    CXXFLAGS += -fno-stack-protector $(call, cc-option,-fno-pie)
 else
     # Override the cflags with Kconfig-specified flags
 	CFLAGS += ${CONFIG_USER_CFLAGS}

from sel4-tutorials.

wom-bat avatar wom-bat commented on August 18, 2024

Looks like this patch (or an equivalent) is already in later versions of seL4.

from sel4-tutorials.

wom-bat avatar wom-bat commented on August 18, 2024

To try a later version of seL4, do repo sync -m sel4-tutorials-master.xml -- this will pick up the bleeding edge.

from sel4-tutorials.

statusfailed avatar statusfailed commented on August 18, 2024

Hooray, both your suggestions work!

With patch:

Starting node #0
Hello, World
Ignoring call to sys_exit_group

Without patch:

Hello, World

Either way: thank you very much for your help!

p.s.: I'm curious why the repo sync -m sel4-tutorials-master.xml is different to the initial mkdir ... cd ... repo init ... repo sync dance. What is repo sync -m ... doing that the original repo sync isn't?

from sel4-tutorials.

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.