2.6.8-rc4-mm1 - Fix UML build
Subsystems (2)
PATCH 1/3 2.6.8-rc4-mm1 - Fix UML build
The patch below makes UML build in the face of the ldchk addition to 2.6.8. The basic problem for UML is that it has always had a two-stage link to produce the final executable -
vmlinux contains all the kernel bits, but no libc or gcc libs linux is vmlinux plus another .o, massaged by gcc, and linked against
libc
This means that, for UML, vmlinux will have unresolved symbols, and will fail the ldchk test.
I fixed this in a reasonably nasty way by
adding a $(post-y) to the end of the list of objects defining it to be
some link flags, an object, and a library from the old linux
link command
a set of libraries pulled from the output of 'gcc -v'
adding a -L flag to LDFLAGS_vmlinux which points at the location of
the -lgcc, etc libraries - this is determined by using 'gcc -v' to figure out where its spec file is located and assuming that its libraries will be located in the same place
adding arch/um/main.o to $(extra-y) in arch/um/kernel/Makefile because
I couldn't figure out how to get it to build from arch/um/Makefile
This is all inside UML, except for the $(post-y) in the top-level Makefile.
With this, vmlinux contains all the bits needed for UML, and passes the ldchk test. However, it won't run, and a gcc run is needed in order to produce a real executable. gcc needs to polish the bits or something.
This getting entirely too familiar with gcc, and I'd appreciate clues about how to back out of this. Ideally, I'd like to use the gcc driver as the vmlinux linker, but that would require at least rewriting the command, so I'm not sure how practical that is.
Anyway, you have been warned. Here it is. Andrew, please apply.
Jeff
Makefile +1 -0
@@ -519,6 +519,7 @@ $(drivers-y) \ $(net-y) \ --end-group \ + $(post-y) \ $(filter .tmp_kallsyms%,$^) \ -o $@ endef
arch/um/Makefile +9 -3
@@ -21,6 +21,10 @@ $(ARCH_DIR)/drivers/ \ $(ARCH_DIR)/sys-$(SUBARCH)/ +post-y = --wrap malloc --wrap free --wrap calloc \ + $(ARCH_DIR)/main.o -lutil \ + --start-group -lgcc -lgcc_eh -lc --end-group + # Have to precede the include because the included Makefiles reference them. SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \ arch-signal.h module.h
@@ -84,7 +88,10 @@ prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) -LDFLAGS_vmlinux = -r +# This stupidity extracts the directory in which gcc lives so that it can +# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage. +LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`) +LDFLAGS_vmlinux = -L/usr/lib -L$(LD_DIR) -r vmlinux: $(ARCH_DIR)/main.o
@@ -126,8 +133,7 @@ # $(call if_changed_dep,as_s_S) linux: vmlinux $(LD_SCRIPT-y) - $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \ - -o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil + $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) -o linux vmlinux USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
arch/um/kernel/Makefile +2 -2
@@ -3,7 +3,7 @@ # Licensed under the GPL # -extra-y := vmlinux.lds.s +extra-y := vmlinux.lds.s ../main.o obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \ helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
@@ -24,7 +24,7 @@ user-objs-$(CONFIG_TTY_LOG) += tty_log.o USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ - process.o tempfile.o time.o tty_log.o umid.o user_util.o + process.o tempfile.o time.o tty_log.o umid.o user_util.o ../main.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
arch/um/kernel/vmlinux.lds.S +2 -3
@@ -42,11 +42,10 @@ #include "asm/common.lds.S" - init.data : { *(init.data) } + .init.data : { *(init.data) } + .data.init_task : { *(.data.init_task) } .data : { - . = ALIGN(KERNEL_STACK_SIZE); /* init_task */ - *(.data.init_task) *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS
arch/um/sys-i386/Makefile +4 -3
@@ -1,5 +1,5 @@ -obj-y = bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o ptrace_user.o \ - semaphore.o sigcontext.o syscalls.o sysrq.o time.o +obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \ + ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_MODULES) += module.o
@@ -7,11 +7,12 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) -SYMLINKS = semaphore.c highmem.c module.c +SYMLINKS = bitops.c semaphore.c highmem.c module.c SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f) clean-files := $(SYMLINKS) +bitops.c-dir = lib semaphore.c-dir = kernel highmem.c-dir = mm module.c-dir = kernel
arch/um/uml.lds.S +2 -8
@@ -11,15 +11,9 @@ __binary_start = .; #ifdef MODE_TT - .thread_private : { - __start_thread_private = .; - errno = .; - . += 4; - arch/um/kernel/tt/unmap_fin.o (.data) - __end_thread_private = .; - } + .thread_private : { *(.thread_private) } . = ALIGN(4096); - .remap : { arch/um/kernel/tt/unmap_fin.o (.text) } + .remap : { *(.remap) } #endif . = ALIGN(4096); /* Init code and data */
Quoted 2 lines · Jeff Dike
The patch below makes UML build in the face of the ldchk addition to 2.6.8.
Confused. Your vmlinux.lds.S doesn't look anything like mine:
#include <asm-generic/vmlinux.lds.h>
OUTPUT_FORMAT(ELF_FORMAT)OUTPUT_ARCH(ELF_ARCH)ENTRY(_start)
jiffies = jiffies_64;
SECTIONS
{
#include "asm/common.lds.S"
}
Quoted 1 line · [email protected] said:
Confused.
So was I for a while :-)
Quoted 1 line
Your
vmlinux.lds.Sdoesn't look anything like mine:
My apologies. A combination of a mashed stock tree and some quilt lossage at my end caused some bogus patches and let them pass my sanity tests.
Here is a fixed fix-build patch, against 2.6.8.1-mm1.
The undefined symbol checking is continuing to cause UML pain. This time, it picked up a bunch of 'w' symbols as undefined. They were present in the 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added them as a second special case to mksysmap (and I just noticed that I forgot a comment there - I can submit a patch for that if there's demand for one).
Jeff
Makefile +1 -0
@@ -523,6 +523,7 @@ $(drivers-y) \ $(net-y) \ --end-group \ + $(post-y) \ $(filter .tmp_kallsyms%,$^) \ -o $@ endef
arch/um/Makefile +24 -6
@@ -21,6 +21,10 @@ $(ARCH_DIR)/drivers/ \ $(ARCH_DIR)/sys-$(SUBARCH)/ +post-y = --wrap malloc --wrap free --wrap calloc \ + $(ARCH_DIR)/main.o -lutil \ + --start-group -lgcc -lgcc_eh -lc --end-group + # Have to precede the include because the included Makefiles reference them. SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \ arch-signal.h module.h
@@ -84,7 +88,10 @@ prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) -LDFLAGS_vmlinux = -r +# This stupidity extracts the directory in which gcc lives so that it can +# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage. +LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`) +LDFLAGS_vmlinux = -L/usr/lib -L$(LD_DIR) -r vmlinux: $(ARCH_DIR)/main.o
@@ -117,17 +124,28 @@ -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \ -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \ -DKERNEL_STACK_SIZE=$(STACK_SIZE)) +CPPFLAGS_$(LD_SCRIPT-y) = $(CPPFLAGS_vmlinux.lds) -P -C -Uum -export CPPFLAGS_$(LD_SCRIPT-y) = $(CPPFLAGS_vmlinux.lds) -P -C -Uum +export CPPFLAGS_$(LD_SCRIPT-y) LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y) -#$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE -# $(call if_changed_dep,as_s_S) +# More kbuild lossage - I can't get uml.lds to fire the %.lds : %.lds.S rule. +# It always ends up going into the .S assembly rule. So, an explicit rule +# here works around that. Then, it turns out that cmd_cpp_lds_S is undefined, +# which I don't understand since I would have thought that the entire Makefile +# had been read by the time it executes commands. So, defining that here works +# around that. Then, it turns out that cpp_flags isn't defined, which I don't +# understand for the same reason. So, I just included the expansion here, +# and after much grossness, you get a building and working UML. +quiet_cmd_cpp_lds_S = LDS $@ + cmd_cpp_lds_S = $(CPP) -Wp,-MD,$(depfile) -Iinclude $(CPPFLAGS_vmlinux.lds) -P -C -Uum $(NOSTDINC_FLAGS) -D__ASSEMBLY__ -o $@ $< + +$(LD_SCRIPT-y) : $(LD_SCRIPT-y).S scripts FORCE + $(call if_changed_dep,cpp_lds_S) linux: vmlinux $(LD_SCRIPT-y) - $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \ - -o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil + $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) -o linux vmlinux USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
arch/um/kernel/Makefile +2 -2
@@ -3,7 +3,7 @@ # Licensed under the GPL # -extra-y := vmlinux.lds +extra-y := vmlinux.lds ../main.o obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \ helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
@@ -24,7 +24,7 @@ user-objs-$(CONFIG_TTY_LOG) += tty_log.o USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ - process.o tempfile.o time.o tty_log.o umid.o user_util.o + process.o tempfile.o time.o tty_log.o umid.o user_util.o ../main.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
arch/um/kernel/vmlinux.lds.S +85 -1
90 lines not on this page · raw message
arch/um/sys-i386/Makefile +4 -3
@@ -1,5 +1,5 @@ -obj-y = bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o ptrace_user.o \ - semaphore.o sigcontext.o syscalls.o sysrq.o time.o +obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \ + ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_MODULES) += module.o
@@ -7,11 +7,12 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) -SYMLINKS = semaphore.c highmem.c module.c +SYMLINKS = bitops.c semaphore.c highmem.c module.c SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f) clean-files := $(SYMLINKS) +bitops.c-dir = lib semaphore.c-dir = kernel highmem.c-dir = mm module.c-dir = kernel
arch/um/uml.lds.S +2 -8
@@ -11,15 +11,9 @@ __binary_start = .; #ifdef MODE_TT - .thread_private : { - __start_thread_private = .; - errno = .; - . += 4; - arch/um/kernel/tt/unmap_fin.o (.data) - __end_thread_private = .; - } + .thread_private : { *(.thread_private) } . = ALIGN(4096); - .remap : { arch/um/kernel/tt/unmap_fin.o (.text) } + .remap : { *(.remap) } #endif . = ALIGN(4096); /* Init code and data */
scripts/mksysmap +1 -1
@@ -18,7 +18,7 @@ # they are used by the sparc BTFIXUP logic - and is assumed to be undefined. -if [ "`$NM -u $1 | grep -v ' ___'`" != "" ]; then +if [ "`$NM -u $1 | grep -v '\( ___\)\|\(^ *w \)'`" != "" ]; then echo "$1: error: undefined symbol(s) found:" $NM -u $1 | grep -v ' ___' exit 1
Quoted 5 lines · Jeff Dike
The undefined symbol checking is continuing to cause UML pain. This time, it picked up a bunch of 'w' symbols as undefined. They were present in the 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added them as a second special case to mksysmap (and I just noticed that I forgot a comment there - I can submit a patch for that if there's demand for one).
Likewise for sparc64; the 'w' symbols are showing up as 'undefined' there too. Probably because [^w] isn't behaving as expected.
-- wli
Quoted 11 lines · William Lee Irwin III
Quoted 5 lines · Jeff Dike
The undefined symbol checking is continuing to cause UML pain. This time, it picked up a bunch of 'w' symbols as undefined. They were present in the 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added them as a second special case to mksysmap (and I just noticed that I forgot a comment there - I can submit a patch for that if there's demand for one).
Likewise for sparc64; the 'w' symbols are showing up as 'undefined' there too. Probably because [^w] isn't behaving as expected.
Sigh. That patch is causing a ton of grief. But Russell's reasons for needing it on ARM were solid, and it is a bit weird for any architecture to have undefined symbols in vmlinux. I guess we persist.
Quoted 9 lines · Andrew Morton
Quoted 8 lines · William Lee Irwin III
Quoted 5 lines · Jeff Dike
The undefined symbol checking is continuing to cause UML pain. This time, it picked up a bunch of 'w' symbols as undefined. They were present in the 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added them as a second special case to mksysmap (and I just noticed that I forgot a comment there - I can submit a patch for that if there's demand for one).
Quoted 7 lines
Quoted 3 lines
Likewise for sparc64; the 'w' symbols are showing up as 'undefined' there too. Probably because [^w] isn't behaving as expected.
Sigh. That patch is causing a ton of grief. But Russell's reasons for needing it on ARM were solid, and it is a bit weird for any architecture to have undefined symbols in vmlinux. I guess we persist.
Please note that the functionality is moved to scripts/mksysmap, so Russell's original ldchk needs to be backed out.
Sam
Quoted 14 lines · Sam Ravnborg
Quoted 13 lines · Andrew Morton
Quoted 11 lines · William Lee Irwin III
Quoted 5 lines · Jeff Dike
The undefined symbol checking is continuing to cause UML pain. This time, it picked up a bunch of 'w' symbols as undefined. They were present in the 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added them as a second special case to mksysmap (and I just noticed that I forgot a comment there - I can submit a patch for that if there's demand for one).
Likewise for sparc64; the 'w' symbols are showing up as 'undefined' there too. Probably because [^w] isn't behaving as expected.
Quoted 5 lines
Quoted 3 lines
Sigh. That patch is causing a ton of grief. But Russell's reasons for needing it on ARM were solid, and it is a bit weird for any architecture to have undefined symbols in vmlinux. I guess we persist.
Please note that the functionality is moved to
scripts/mksysmap, so Russell's original ldchk needs to be backed out.
I'm hopeful that the next release of binutils (any ideas when that'll be?) should resolve the various problems I've found.
At that point, I think we should consider whether to keep the check (for possible problems in the future) and/or prevent older ARM binutils building the kernel. That depends whether forcing all ARM people to use the latest and greatest binutils (which may have other issues) is really the best plan...
Signature · 4 lines
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial coreQuoted 2 lines · Jeff Dike
Here is a fixed fix-build patch, against 2.6.8.1-mm1.
Thanks. Where do we stand now with getting all this stuff merged up? Are the patches in -mm suitable? Did the controversial blockdev stuff get cleaned up? (it looks like it did...).
Quoted 3 lines · [email protected] said:
Thanks. Where do we stand now with getting all this stuff merged up? Are the patches in -mm suitable? Did the controversial blockdev stuff get cleaned up? (it looks like it did...).
Not really, the code is still there but it's not built. Below is a patch which removes it totally.
I also have to get rid of ghash.h and fix some inappropriate intimacy between one of the drivers and VFS.
I'd also wouldn't mind breaking up the big UML patch into somewhat more sane pieces. Can I do something like break pieces off it, send them plus the smaller big patch, and have you subsititute them for the current big patch?
Is that preferable to dropping the current patches on Linus, or would you rather send him what you have, in more or less its current form, once it's been tidied up?
Jeff
arch/um/Kconfig_block +1 -11
@@ -29,19 +29,9 @@ wise choice too. In all other cases (for example, if you're just playing around with User-Mode Linux) you can choose N. -# Turn this back on when the driver actually works -# -#config BLK_DEV_COW -# tristate "COW block device" -# help -# This is a layered driver which sits above two other block devices. -# One is read-only, and the other is a read-write layer which stores -# all changes. This provides the illusion that the read-only layer -# can be mounted read-write and changed. - config BLK_DEV_COW_COMMON bool - default BLK_DEV_COW || BLK_DEV_UBD + default BLK_DEV_UBD config BLK_DEV_LOOP tristate "Loopback device support"
arch/um/drivers/Makefile +0 -1
@@ -39,7 +39,6 @@ obj-$(CONFIG_TTY_CHAN) += tty.o obj-$(CONFIG_XTERM_CHAN) += xterm.o xterm_kern.o obj-$(CONFIG_UML_WATCHDOG) += harddog.o -obj-$(CONFIG_BLK_DEV_COW) += cow_kern.o obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o obj-y += stdio_console.o $(CHAN_OBJS)
arch/um/drivers/cow_kern.c +0 -630
630 lines not on this page · raw message
Quoted 8 lines · Jeff Dike
Quoted 3 lines · [email protected] said:
Thanks. Where do we stand now with getting all this stuff merged up? Are the patches in -mm suitable? Did the controversial blockdev stuff get cleaned up? (it looks like it did...).
Not really, the code is still there but it's not built. Below is a patch which removes it totally.
Thanks.
Quoted 2 lines
I also have to get rid of
ghash.hand fix some inappropriate intimacy between one of the drivers and VFS.
OK.
Quoted 3 lines
I'd also wouldn't mind breaking up the big UML patch into somewhat more sane pieces. Can I do something like break pieces off it, send them plus the smaller big patch, and have you subsititute them for the current big patch?
Feel free if you think there's some benefit in that.
Quoted 3 lines
Is that preferable to dropping the current patches on Linus, or would you rather send him what you have, in more or less its current form, once it's been tidied up?
Frankly, when a subsystem gets this far out of date I don't think it matters a lot - nobody has much hope of following all the changes anyway. We'll just merge the megapatch on the assumption that Jeff knows what he's doing, and that it's better than what we had before. You should have seen the size of some of those MIPS patches ;)
Quoted 4 lines · Andrew Morton
Frankly, when a subsystem gets this far out of date I don't think it matters a lot - nobody has much hope of following all the changes anyway. We'll just merge the megapatch on the assumption that Jeff knows what he's doing, and that it's better than what we had before.
Well, that latter is pretty certain, but I wouldn't be too sure about the former :-)
Quoted 2 lines
You should have seen
the size of some of those MIPS patches ;)
Hehe. OK, I'll keep the current big patch, and stack little ones on top of it to fix it.
Jeff
Quoted 5 lines · Andrew Morton
Frankly, when a subsystem gets this far out of date I don't think it matters a lot - nobody has much hope of following all the changes anyway. We'll just merge the megapatch on the assumption that Jeff knows what he's doing, and that it's better than what we had before. You should have seen the size of some of those MIPS patches ;)
I've been pushing for a large giant UML merge for ages, mostly as nobody is looking over the broken down patches much anyhow...
I'd even be happy with the current stuff being shoved into mainline even if it doesn't build for a few days until it gets fixed --- not having a common point of reference is really quite frustrating.
There are a ton of white-space cleanups and sparsification changes that could be done too --- I assume this would be best done *before* a giant-patch merge?
--cw
arch/um/Makefile line 93
Quoted 8 lines · Jeff Dike
arch/um/Makefile +3
-1@@ -84,7 +88,10 @@ prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) -LDFLAGS_vmlinux = -r +# This stupidity extracts the directory in which gcc lives so that it can +# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage. +LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`)
Try gcc -print-search-dirs.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line · [email protected] said:
Try gcc -print-search-dirs.
Ah, excellent, thanks very much. I had looked around gcc's info, but I missed that.
Jeff