Skip to contentSkip to conversation

arch: um: fix error when linking vmlinux.

PATCH Applied Lorenzo Colitti 2 participants 2 messages Nov 18, 2015 – Dec 8, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch: um: fix error when linking vmlinux.

On gcc Ubuntu 4.8.4-2ubuntu1~14.04, linking vmlinux fails with:

arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference to timer_create' arch/um/os-Linux/built-in.o: In function os_timer_set_interval':
/android/kernel/android/arch/um/os-Linux/time.c:84: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_remain':
/android/kernel/android/arch/um/os-Linux/time.c:109: undefined reference to timer_gettime' arch/um/os-Linux/built-in.o: In function os_timer_one_shot':
/android/kernel/android/arch/um/os-Linux/time.c:132: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_disable':
/android/kernel/android/arch/um/os-Linux/time.c:145: undefined reference to `timer_settime'

This is because -lrt appears in the generated link commandline after arch/um/os-Linux/built-in.o. Fix this by removing -lrt from arch/um/Makefile and adding it to the UM-specific section of scripts/link-vmlinux.sh.

---
 arch/um/Makefile        | 2 +-
 scripts/link-vmlinux.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/um/Makefile +1 -1
index 25ed409..e3abe6f 100644
@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT)
 # The wrappers will select whether using "malloc" or the kernel allocator.
 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
 
-LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt
+LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
 
 # Used by link-vmlinux.sh which has special support for um link
 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
scripts/link-vmlinux.sh +1 -1
index 1a10d8a..dacf71a 100755
@@ -62,7 +62,7 @@ vmlinux_link()
 			-Wl,--start-group                                    \
 				 ${KBUILD_VMLINUX_MAIN}                      \
 			-Wl,--end-group                                      \
-			-lutil ${1}
+			-lutil -lrt ${1}
 		rm -f linux
 	fi
 }
Signature · 8 lines
2.6.0.rc2.230.g3dd15c0


------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#1 lore raw
Quoted 42 lines · Lorenzo Colitti

On gcc Ubuntu 4.8.4-2ubuntu1~14.04, linking vmlinux fails with:

arch/um/os-Linux/built-in.o: In function `os_timer_create':
/android/kernel/android/arch/um/os-Linux/time.c:51: undefined reference to timer_create' arch/um/os-Linux/built-in.o: In function os_timer_set_interval':
/android/kernel/android/arch/um/os-Linux/time.c:84: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_remain':
/android/kernel/android/arch/um/os-Linux/time.c:109: undefined reference to timer_gettime' arch/um/os-Linux/built-in.o: In function os_timer_one_shot':
/android/kernel/android/arch/um/os-Linux/time.c:132: undefined reference to timer_settime' arch/um/os-Linux/built-in.o: In function os_timer_disable':
/android/kernel/android/arch/um/os-Linux/time.c:145: undefined reference to `timer_settime'

This is because -lrt appears in the generated link commandline after arch/um/os-Linux/built-in.o. Fix this by removing -lrt from arch/um/Makefile and adding it to the UM-specific section of scripts/link-vmlinux.sh.

---
 arch/um/Makefile        | 2 +-
 scripts/link-vmlinux.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/um/Makefile +1 -1
index 25ed409..e3abe6f 100644
@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT)
 # The wrappers will select whether using "malloc" or the kernel allocator.
 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
 
-LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt
+LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
 
 # Used by link-vmlinux.sh which has special support for um link
 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
scripts/link-vmlinux.sh +0 -0
index 1a10d8a..dacf71a 100755

scripts/link-vmlinux.sh vmlinux_link()

Quoted 9 lines
scripts/link-vmlinux.sh +1 -2
@@ -62,7 +62,7 @@ vmlinux_link()
                        -Wl,--start-group                                    \
                                 ${KBUILD_VMLINUX_MAIN}                      \
                        -Wl,--end-group                                      \
-                       -lutil ${1}
+                       -lutil -lrt ${1}
                rm -f linux
        fi
 }
--

Applied! :)

Signature · 8 lines
Thanks,
//richard

------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel