Skip to contentSkip to conversation

fix ia64, tile, sh for thin archives

PATCH In review Nicholas Piggin 2 participants 15 messages Jun 22, 2017 – Jun 25, 2017

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

PATCH v2 1/3 sh: thin archives fix linking

In reply to Nicholas Piggin

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/sh/kernel/vsyscall/Makefile +9 -7
index 8f0ea5fc835c..efc7a6837ef6 100644
@@ -1,4 +1,4 @@
-obj-y += vsyscall.o vsyscall-syscall.o
+obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o
 
 $(obj)/vsyscall-syscall.o: \
 	$(foreach F,trapa,$(obj)/vsyscall-$F.so)
@@ -26,11 +26,13 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vsyscall-syms.o
-$(obj)/built-in.o: $(obj)/vsyscall-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
-
-SYSCFLAGS_vsyscall-syms.o = -r
-$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+SYSCFLAGS_vsyscall-dummy.o = -r
+$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
 			$(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
 	$(call if_changed,syscall)
+
+quiet_cmd_syscall_syms = SYSCALL $@
+      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+	$(call if_changed,syscall_syms)
Signature · 1 line
2.11.0
#6 lore raw

PATCH v2 2/3 ia64: thin archives fix linking

In reply to Nicholas Piggin

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/ia64/kernel/Makefile.gate | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/ia64/kernel/Makefile.gate +7 -5
index a32903ada016..e20c711c2b1e 100644
@@ -2,7 +2,9 @@
 
 targets += gate.so gate-syms.o
 
-extra-y += gate.so gate-syms.o gate.lds gate.o
+obj-y += gate-syms.o
+
+extra-y += gate.so gate.lds gate.o
 
 CPPFLAGS_gate.lds := -P -C -U$(ARCH)
 
@@ -14,12 +16,12 @@ GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \
 $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
 	$(call if_changed,gate)
 
-$(obj)/built-in.o: $(obj)/gate-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o
+# create an object file to resolve gate symbols
+quiet_cmd_gate_syms = GATESYM $@
+      cmd_gate_syms = $(LD) -r -T $(obj)/gate.lds -R $(obj)/gate.o -o $@
 
-GATECFLAGS_gate-syms.o = -r
 $(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
-	$(call if_changed,gate)
+	$(call if_changed,gate_syms)
 
 # gate-data.o contains the gate DSO image as data in section .data..gate.
 # We must build gate.so before we can assemble it.
Signature · 1 line
2.11.0
#0 lore raw

v2 cover fix ia64, tile, sh for thin archives

This is a re-work of the vdso symbol linking patches to avoid the problem,

ld: warning: .note.gnu.build-id section discarded, --build-id ignored.

I was able to reproduce the problem, and I have compiled defconfig for 3 architectures here with this new approach and I saw no problems.

Please replace the existing patches in kbuild/thin-ac with these 3 if you agree with them.

Thanks,
Nick

Nicholas Piggin (3):
sh: thin archives fix linking
ia64: thin archives fix linking
tile: thin archives fix linking

 arch/ia64/kernel/Makefile.gate   | 12 +++++++-----
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 arch/tile/kernel/vdso/Makefile   | 14 ++++++++------
 3 files changed, 24 insertions(+), 18 deletions(-)
Signature · 1 line
2.11.0
#10 lore raw

PATCH v2 3/3 tile: thin archives fix linking

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/tile/kernel/vdso/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
arch/tile/kernel/vdso/Makefile +8 -6
index c54fff37b5ff..e140472d5be6 100644
@@ -11,7 +11,7 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 # vdso32 is only for tilegx -m32 compat task.
 VDSO32-$(CONFIG_COMPAT) := y
 
-obj-y += vdso.o
+obj-y += vdso.o vdso-syms.o
 obj-$(VDSO32-y) += vdso32.o
 extra-y += vdso.lds
 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
@@ -49,16 +49,18 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vdso-syms.o
-$(obj)/built-in.o: $(obj)/vdso-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
 
 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
                             $(call cc-ldoption, -Wl$(comma)--hash-style=both)
-SYSCFLAGS_vdso_syms.o = -r
-$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
+SYSCFLAGS_vdso_dummy.o = -r
+$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
 	$(call if_changed,vdsold)
 
+quiet_cmd_vdso_sym = VDSOSYM $@
+      cmd_vdso_sym = $(LD) -r -R $(obj)/vdso-dummy.o -o $@
+
+$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o
+	$(call if_changed,vdso_sym)
 
 # strip rule for the .so file
 $(obj)/%.so: OBJCOPYFLAGS := -S
Signature · 1 line
2.11.0
#13 lore raw
In reply to Nicholas Piggin

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 11 lines

This is a re-work of the vdso symbol linking patches to avoid the problem,

ld: warning: .note.gnu.build-id section discarded, --build-id ignored.

I was able to reproduce the problem, and I have compiled defconfig for 3 architectures here with this new approach and I saw no problems.

Please replace the existing patches in kbuild/thin-ac with these 3 if you agree with them.

I did so. Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

Re: [PATCH v2 1/3] sh: thin archives fix linking

In reply to Nicholas Piggin

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 43 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/sh/kernel/vsyscall/Makefile +9 -8
index 8f0ea5fc835c..efc7a6837ef6 100644
@@ -1,4 +1,4 @@
-obj-y += vsyscall.o vsyscall-syscall.o
+obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o
 
 $(obj)/vsyscall-syscall.o: \
        $(foreach F,trapa,$(obj)/vsyscall-$F.so)
@@ -26,11 +26,13 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vsyscall-syms.o
-$(obj)/built-in.o: $(obj)/vsyscall-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
-
-SYSCFLAGS_vsyscall-syms.o = -r
-$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+SYSCFLAGS_vsyscall-dummy.o = -r
+$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
                        $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
        $(call if_changed,syscall)
+
+quiet_cmd_syscall_syms = SYSCALL $@
+      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+       $(call if_changed,syscall_syms)
--
Quoted 1 line

2.11.0

I applied this, but
I just noticed vsyscall-dummy is rebuilt every time.

SYSCALL arch/sh/kernel/vsyscall/vsyscall-dummy.o SYSCALL arch/sh/kernel/vsyscall/vsyscall-syms.o
AR arch/sh/kernel/vsyscall/built-in.o
AR arch/sh/kernel/built-in.o

We can avoid the unneeded rebuild by adding "vsyscall-dummy.o" to "targets".

targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o

Signature · 2 lines
Best Regards
Masahiro Yamada
#14 lore raw
In reply to Masahiro Yamada
Quoted 6 lines · On Fri, 23 Jun 2017 12:23:48 +0900 Masahiro Yamada…

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 5 lines

This is a re-work of the vdso symbol linking patches to avoid the problem,

ld: warning: .note.gnu.build-id section discarded, --build-id ignored.

Quoted 11 lines
Quoted 6 lines

I was able to reproduce the problem, and I have compiled defconfig for 3 architectures here with this new approach and I saw no problems.

Please replace the existing patches in kbuild/thin-ac with these 3 if you agree with them.

I did so. Thanks!

Thank you Yamada san, will you merge David's patch for sparc64 as well?

Thanks,
Nick

#3 lore raw

Re: [PATCH v2 1/3] sh: thin archives fix linking

In reply to Masahiro Yamada
Quoted 57 lines · On Fri, 23 Jun 2017 12:25:10 +0900 Masahiro Yamada…

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 43 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/sh/kernel/vsyscall/Makefile +9 -8
index 8f0ea5fc835c..efc7a6837ef6 100644
@@ -1,4 +1,4 @@
-obj-y += vsyscall.o vsyscall-syscall.o
+obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o
 
 $(obj)/vsyscall-syscall.o: \
        $(foreach F,trapa,$(obj)/vsyscall-$F.so)
@@ -26,11 +26,13 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vsyscall-syms.o
-$(obj)/built-in.o: $(obj)/vsyscall-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
-
-SYSCFLAGS_vsyscall-syms.o = -r
-$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+SYSCFLAGS_vsyscall-dummy.o = -r
+$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
                        $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
        $(call if_changed,syscall)
+
+quiet_cmd_syscall_syms = SYSCALL $@
+      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+       $(call if_changed,syscall_syms)
--
Quoted 1 line

2.11.0

I applied this, but
I just noticed vsyscall-dummy is rebuilt every time.

SYSCALL arch/sh/kernel/vsyscall/vsyscall-dummy.o SYSCALL arch/sh/kernel/vsyscall/vsyscall-syms.o
AR arch/sh/kernel/vsyscall/built-in.o
AR arch/sh/kernel/built-in.o

Quoted 3 lines

We can avoid the unneeded rebuild by adding "vsyscall-dummy.o" to "targets".

targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o

Thanks, good catch. The tile patch may have the same issue?

#7 lore raw

Re: [PATCH v2 2/3] ia64: thin archives fix linking

In reply to Nicholas Piggin

Hi Nicholas,

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 45 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/ia64/kernel/Makefile.gate | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/ia64/kernel/Makefile.gate +7 -6
index a32903ada016..e20c711c2b1e 100644
@@ -2,7 +2,9 @@
 
 targets += gate.so gate-syms.o
 
-extra-y += gate.so gate-syms.o gate.lds gate.o
+obj-y += gate-syms.o
+
+extra-y += gate.so gate.lds gate.o
 
 CPPFLAGS_gate.lds := -P -C -U$(ARCH)
 
@@ -14,12 +16,12 @@ GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \
 $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
        $(call if_changed,gate)
 
-$(obj)/built-in.o: $(obj)/gate-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o
+# create an object file to resolve gate symbols
+quiet_cmd_gate_syms = GATESYM $@
+      cmd_gate_syms = $(LD) -r -T $(obj)/gate.lds -R $(obj)/gate.o -o $@
 
-GATECFLAGS_gate-syms.o = -r
 $(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
-       $(call if_changed,gate)
+       $(call if_changed,gate_syms)
 
 # gate-data.o contains the gate DSO image as data in section .data..gate.
 # We must build gate.so before we can assemble it.
--
Quoted 1 line

2.11.0

Build test passed, but the symbol table seems different.

For example, __kernel_sigtramp will change
a000000000040740 T __kernel_sigtramp
to
0000000000000020 A __kernel_sigtramp

Without this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
a000000000000600 D __start_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_vtop_patchlist
a000000000000604 D __start_gate_fsyscall_patchlist
a000000000000604 D __start_gate_vtop_patchlist
a000000000000608 D __end_gate_fsyscall_patchlist
a000000000000608 D __start_gate_brl_fsys_bubble_down_patchlist
a00000000000060c D __end_gate_brl_fsys_bubble_down_patchlist
a000000000040720 T __kernel_syscall_via_break
a000000000040740 T __kernel_sigtramp
a000000000040770 t back_from_setup_rbs
a000000000040830 t back_from_restore_rbs
a0000000000408a0 t setup_rbs
a000000000040900 t restore_rbs
a000000000040a00 T __kernel_syscall_via_epc
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep  __kernel_sigtramp
a000000000040740 A __kernel_sigtramp

With this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
0000000000000000 A __kernel_syscall_via_break
0000000000000020 A __kernel_sigtramp
00000000000002e0 A __kernel_syscall_via_epc
a000000000000600 D __end_gate_brl_fsys_bubble_down_patchlist
a000000000000600 D __end_gate_fsyscall_patchlist
a000000000000600 D __end_gate_mckinley_e9_patchlist
a000000000000600 D __end_gate_vtop_patchlist
a000000000000600 D __start_gate_brl_fsys_bubble_down_patchlist
a000000000000600 D __start_gate_fsyscall_patchlist
a000000000000600 D __start_gate_mckinley_e9_patchlist
a000000000000600 D __start_gate_vtop_patchlist
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep __kernel_sigtramp
0000000000000020 A __kernel_sigtramp

Could you check it?

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

Re: [PATCH v2 1/3] sh: thin archives fix linking

In reply to Nicholas Piggin

2017-06-23 12:50 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 60 lines
Quoted 57 lines · On Fri, 23 Jun 2017 12:25:10 +0900 Masahiro Yamada…

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 43 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/sh/kernel/vsyscall/Makefile +9 -8
index 8f0ea5fc835c..efc7a6837ef6 100644
@@ -1,4 +1,4 @@
-obj-y += vsyscall.o vsyscall-syscall.o
+obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o
 
 $(obj)/vsyscall-syscall.o: \
        $(foreach F,trapa,$(obj)/vsyscall-$F.so)
@@ -26,11 +26,13 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vsyscall-syms.o
-$(obj)/built-in.o: $(obj)/vsyscall-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
-
-SYSCFLAGS_vsyscall-syms.o = -r
-$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+SYSCFLAGS_vsyscall-dummy.o = -r
+$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
                        $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
        $(call if_changed,syscall)
+
+quiet_cmd_syscall_syms = SYSCALL $@
+      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+       $(call if_changed,syscall_syms)
--
Quoted 1 line

2.11.0

I applied this, but
I just noticed vsyscall-dummy is rebuilt every time.

SYSCALL arch/sh/kernel/vsyscall/vsyscall-dummy.o SYSCALL arch/sh/kernel/vsyscall/vsyscall-syms.o
AR arch/sh/kernel/vsyscall/built-in.o
AR arch/sh/kernel/built-in.o

Quoted 6 lines
Quoted 3 lines

We can avoid the unneeded rebuild by adding "vsyscall-dummy.o" to "targets".

targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o

Thanks, good catch. The tile patch may have the same issue? --

I think so.

One more fix.

+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+ $(call if_changed,syscall_syms)

$(call if_changed,...) must have FORCE in the dependency field. Otherwise, if_changed may not be evaluated.

I can fix up it locally. :-)

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

Re: [PATCH v2 2/3] ia64: thin archives fix linking

In reply to Masahiro Yamada
Quoted 45 lines · On Fri, 23 Jun 2017 18:56:32 +0900 Masahiro Yamada…

Hi Nicholas,

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Without this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
a000000000000600 D __start_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_vtop_patchlist
a000000000000604 D __start_gate_fsyscall_patchlist
a000000000000604 D __start_gate_vtop_patchlist
a000000000000608 D __end_gate_fsyscall_patchlist
a000000000000608 D __start_gate_brl_fsys_bubble_down_patchlist
a00000000000060c D __end_gate_brl_fsys_bubble_down_patchlist
a000000000040720 T __kernel_syscall_via_break
a000000000040740 T __kernel_sigtramp
a000000000040770 t back_from_setup_rbs
a000000000040830 t back_from_restore_rbs
a0000000000408a0 t setup_rbs
a000000000040900 t restore_rbs
a000000000040a00 T __kernel_syscall_via_epc
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep  __kernel_sigtramp
a000000000040740 A __kernel_sigtramp

With this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
0000000000000000 A __kernel_syscall_via_break

0000000000000020 A __kernel_sigtramp 00000000000002e0 A __kernel_syscall_via_epc a000000000000600 D __end_gate_brl_fsys_bubble_down_patchlist a000000000000600 D __end_gate_fsyscall_patchlist a000000000000600 D __end_gate_mckinley_e9_patchlist a000000000000600 D __end_gate_vtop_patchlist a000000000000600 D __start_gate_brl_fsys_bubble_down_patchlist a000000000000600 D __start_gate_fsyscall_patchlist a000000000000600 D __start_gate_mckinley_e9_patchlist a000000000000600 D __start_gate_vtop_patchlist

Quoted 5 lines
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep __kernel_sigtramp
0000000000000020 A __kernel_sigtramp

Could you check it?

Sorry about this, thank you for catching it.

This needs a dummy .o file as well. It seems we cannot do both -T and -R operations in one step. This patch follows more like sh and tile fixes.

Thanks,
Nick

---
 arch/ia64/kernel/Makefile.gate | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
arch/ia64/kernel/Makefile.gate +12 -6
index a32903ada016..e8ca862e7b21 100644
@@ -1,8 +1,10 @@
 # The gate DSO image is built using a special linker script.
 
-targets += gate.so gate-syms.o
+targets += gate.so gate-syms.o gate-dummy.o
 
-extra-y += gate.so gate-syms.o gate.lds gate.o
+obj-y += gate-syms.o
+
+extra-y += gate.so gate.lds gate.o
 
 CPPFLAGS_gate.lds := -P -C -U$(ARCH)
 
@@ -14,13 +16,17 @@ GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \
 $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
 	$(call if_changed,gate)
 
-$(obj)/built-in.o: $(obj)/gate-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o
+# create an object file to resolve gate symbols
+quiet_cmd_gate_syms = GATESYM $@
+      cmd_gate_syms = $(LD) -r -R $(obj)/gate-dummy.o -o $@
 
-GATECFLAGS_gate-syms.o = -r
-$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
+GATECFLAGS_gate-dummy.o = -r
+$(obj)/gate-dummy.o: $(obj)/gate.lds $(obj)/gate.o FORCE
 	$(call if_changed,gate)
 
+$(obj)/gate-syms.o: $(obj)/gate-dummy.o FORCE
+	$(call if_changed,gate_syms)
+
 # gate-data.o contains the gate DSO image as data in section .data..gate.
 # We must build gate.so before we can assemble it.
 # Note: kbuild does not track this dependency due to usage of .incbin
Signature · 1 line
2.11.0
#5 lore raw

Re: [PATCH v2 1/3] sh: thin archives fix linking

In reply to Masahiro Yamada

2017-06-23 19:02 GMT+09:00 Masahiro Yamada <[email protected]>:

Quoted 74 lines

2017-06-23 12:50 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 60 lines
Quoted 57 lines · On Fri, 23 Jun 2017 12:25:10 +0900 Masahiro Yamada…

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 43 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/sh/kernel/vsyscall/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/sh/kernel/vsyscall/Makefile +9 -8
index 8f0ea5fc835c..efc7a6837ef6 100644
@@ -1,4 +1,4 @@
-obj-y += vsyscall.o vsyscall-syscall.o
+obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o
 
 $(obj)/vsyscall-syscall.o: \
        $(foreach F,trapa,$(obj)/vsyscall-$F.so)
@@ -26,11 +26,13 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vsyscall-syms.o
-$(obj)/built-in.o: $(obj)/vsyscall-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
-
-SYSCFLAGS_vsyscall-syms.o = -r
-$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+SYSCFLAGS_vsyscall-dummy.o = -r
+$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
                        $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
        $(call if_changed,syscall)
+
+quiet_cmd_syscall_syms = SYSCALL $@
+      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+       $(call if_changed,syscall_syms)
--
Quoted 1 line

2.11.0

I applied this, but
I just noticed vsyscall-dummy is rebuilt every time.

SYSCALL arch/sh/kernel/vsyscall/vsyscall-dummy.o SYSCALL arch/sh/kernel/vsyscall/vsyscall-syms.o
AR arch/sh/kernel/vsyscall/built-in.o
AR arch/sh/kernel/built-in.o

Quoted 6 lines
Quoted 3 lines

We can avoid the unneeded rebuild by adding "vsyscall-dummy.o" to "targets".

targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o

Thanks, good catch. The tile patch may have the same issue? --

I think so.

One more fix.

Quoted 9 lines

+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+ $(call if_changed,syscall_syms)

$(call if_changed,...) must have FORCE in the dependency field. Otherwise, if_changed may not be evaluated.

I can fix up it locally. :-)

I updated thin-ar branch.

Just in case, the following is my local fix-up:

- Fix incremental build
- Do not repeat "$(obj)/vsyscall-dummy.o" in the build command

arch/sh/kernel/vsyscall/Makefile +3 -3
index efc7a68..99685e5 100644
@@ -5,7 +5,7 @@ $(obj)/vsyscall-syscall.o: \
 
 # Teach kbuild about targets
 targets += $(foreach F,trapa,vsyscall-$F.o vsyscall-$F.so)
-targets += vsyscall-note.o vsyscall.lds
+targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o
 
 # The DSO images are built using a special linker script
 quiet_cmd_syscall = SYSCALL $@
@@ -32,7 +32,7 @@ $(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \
        $(call if_changed,syscall)
 
 quiet_cmd_syscall_syms = SYSCALL $@
-      cmd_syscall_syms = $(LD) -r -R $(obj)/vsyscall-dummy.o -o $@
+      cmd_syscall_syms = $(LD) -r -o $@ -R $<
 
-$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o
+$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o FORCE
        $(call if_changed,syscall_syms)
Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw

Re: [PATCH v2 2/3] ia64: thin archives fix linking

In reply to Nicholas Piggin

2017-06-23 22:44 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 96 lines
Quoted 45 lines · On Fri, 23 Jun 2017 18:56:32 +0900 Masahiro Yamada…

Hi Nicholas,

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Without this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
a000000000000600 D __start_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_mckinley_e9_patchlist
a000000000000604 D __end_gate_vtop_patchlist
a000000000000604 D __start_gate_fsyscall_patchlist
a000000000000604 D __start_gate_vtop_patchlist
a000000000000608 D __end_gate_fsyscall_patchlist
a000000000000608 D __start_gate_brl_fsys_bubble_down_patchlist
a00000000000060c D __end_gate_brl_fsys_bubble_down_patchlist
a000000000040720 T __kernel_syscall_via_break
a000000000040740 T __kernel_sigtramp
a000000000040770 t back_from_setup_rbs
a000000000040830 t back_from_restore_rbs
a0000000000408a0 t setup_rbs
a000000000040900 t restore_rbs
a000000000040a00 T __kernel_syscall_via_epc
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep  __kernel_sigtramp
a000000000040740 A __kernel_sigtramp

With this patch,

$ ia64-linux-nm -n arch/ia64/kernel/gate-syms.o
0000000000000000 A __kernel_syscall_via_break

0000000000000020 A __kernel_sigtramp 00000000000002e0 A __kernel_syscall_via_epc a000000000000600 D __end_gate_brl_fsys_bubble_down_patchlist a000000000000600 D __end_gate_fsyscall_patchlist a000000000000600 D __end_gate_mckinley_e9_patchlist a000000000000600 D __end_gate_vtop_patchlist a000000000000600 D __start_gate_brl_fsys_bubble_down_patchlist a000000000000600 D __start_gate_fsyscall_patchlist a000000000000600 D __start_gate_mckinley_e9_patchlist a000000000000600 D __start_gate_vtop_patchlist

Quoted 5 lines
$ ia64-linux-nm -n arch/ia64/kernel/built-in.o | grep __kernel_sigtramp
0000000000000020 A __kernel_sigtramp

Could you check it?

Sorry about this, thank you for catching it.

This needs a dummy .o file as well. It seems we cannot do both -T and -R operations in one step. This patch follows more like sh and tile fixes.

Thanks,
Nick

---
 arch/ia64/kernel/Makefile.gate | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
arch/ia64/kernel/Makefile.gate +8 -6
index a32903ada016..e8ca862e7b21 100644
@@ -1,8 +1,10 @@
 # The gate DSO image is built using a special linker script.
 
-targets += gate.so gate-syms.o
+targets += gate.so gate-syms.o gate-dummy.o
 
-extra-y += gate.so gate-syms.o gate.lds gate.o
+obj-y += gate-syms.o
+
+extra-y += gate.so gate.lds gate.o
 
 CPPFLAGS_gate.lds := -P -C -U$(ARCH)
 
@@ -14,13 +16,17 @@ GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \
 $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
        $(call if_changed,gate)
 
-$(obj)/built-in.o: $(obj)/gate-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o
+# create an object file to resolve gate symbols
+quiet_cmd_gate_syms = GATESYM $@
+      cmd_gate_syms = $(LD) -r -R $(obj)/gate-dummy.o -o $@
 
-GATECFLAGS_gate-syms.o = -r
-$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
+GATECFLAGS_gate-dummy.o = -r

arch/ia64/kernel/Makefile.gate GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \

Quoted 10 lines
arch/ia64/kernel/Makefile.gate +4 -1
+$(obj)/gate-dummy.o: $(obj)/gate.lds $(obj)/gate.o FORCE
        $(call if_changed,gate)
 
+$(obj)/gate-syms.o: $(obj)/gate-dummy.o FORCE
+       $(call if_changed,gate_syms)
+
 # gate-data.o contains the gate DSO image as data in section .data..gate.
 # We must build gate.so before we can assemble it.
 # Note: kbuild does not track this dependency due to usage of .incbin
--

I replaced the patch. Thanks!

I locally changed to the following part to not repeat gate-dummy.o

arch/ia64/kernel/Makefile.gate +1 -1
index e8ca862..8cd125a 100644
@@ -18,7 +18,7 @@ $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
 
 # create an object file to resolve gate symbols
 quiet_cmd_gate_syms = GATESYM $@
-      cmd_gate_syms = $(LD) -r -R $(obj)/gate-dummy.o -o $@
+      cmd_gate_syms = $(LD) -r -o $@ -R $<
 
 GATECFLAGS_gate-dummy.o = -r
 $(obj)/gate-dummy.o: $(obj)/gate.lds $(obj)/gate.o FORCE
Signature · 2 lines
Best Regards
Masahiro Yamada
#11 lore raw

Re: [PATCH v2 3/3] tile: thin archives fix linking

In reply to Nicholas Piggin

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 50 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/tile/kernel/vdso/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
arch/tile/kernel/vdso/Makefile +8 -7
index c54fff37b5ff..e140472d5be6 100644
@@ -11,7 +11,7 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 # vdso32 is only for tilegx -m32 compat task.
 VDSO32-$(CONFIG_COMPAT) := y
 
-obj-y += vdso.o
+obj-y += vdso.o vdso-syms.o
 obj-$(VDSO32-y) += vdso32.o
 extra-y += vdso.lds
 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
@@ -49,16 +49,18 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vdso-syms.o
-$(obj)/built-in.o: $(obj)/vdso-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
 
 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
                             $(call cc-ldoption, -Wl$(comma)--hash-style=both)
-SYSCFLAGS_vdso_syms.o = -r
-$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
+SYSCFLAGS_vdso_dummy.o = -r
+$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
        $(call if_changed,vdsold)
 
+quiet_cmd_vdso_sym = VDSOSYM $@
+      cmd_vdso_sym = $(LD) -r -R $(obj)/vdso-dummy.o -o $@
+
+$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o
+       $(call if_changed,vdso_sym)
 
 # strip rule for the .so file
 $(obj)/%.so: OBJCOPYFLAGS := -S
--

2.11.0

Quoted 1 line

--

I updated thin-ar branch.

Just in case, the following is my local fix-up:

- Fix incremental build
- Do not repeat "$(obj)/vsyscall-dummy.o" in the build command

arch/tile/kernel/vdso/Makefile +1 -1
index edb7809..c615ec0 100644
@@ -5,7 +5,7 @@ vdso-syms = rt_sigreturn gettimeofday
 obj-vdso = $(patsubst %, v%.o, $(vdso-syms))
 
 # Build rules
-targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
+targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 
 # vdso32 is only for tilegx -m32 compat task.
@@ -56,9 +56,9 @@ $(obj)/vdso-dummy.o: $(src)/vdso.lds

$(obj)/vrt_sigreturn.o FORCE

        $(call if_changed,vdsold)

quiet_cmd_vdso_sym = VDSOSYM $@
- cmd_vdso_sym = $(LD) -r -R $(obj)/vdso-dummy.o -o $@
+ cmd_vdso_sym = $(LD) -r -o $@ -R $<

-$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o
+$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE

        $(call if_changed,vdso_sym)
 # strip rule for the .so file
Signature · 2 lines
Best Regards
Masahiro Yamada
#12 lore raw

Re: [PATCH v2 3/3] tile: thin archives fix linking

Quoted 51 lines · On Sun, 25 Jun 2017 12:28:43 +0900 Masahiro Yamada…

2017-06-22 21:39 GMT+09:00 Nicholas Piggin <[email protected]>:

Quoted 50 lines

The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o.

---
 arch/tile/kernel/vdso/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
arch/tile/kernel/vdso/Makefile +8 -7
index c54fff37b5ff..e140472d5be6 100644
@@ -11,7 +11,7 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 # vdso32 is only for tilegx -m32 compat task.
 VDSO32-$(CONFIG_COMPAT) := y
 
-obj-y += vdso.o
+obj-y += vdso.o vdso-syms.o
 obj-$(VDSO32-y) += vdso32.o
 extra-y += vdso.lds
 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
@@ -49,16 +49,18 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
 # these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vdso-syms.o
-$(obj)/built-in.o: $(obj)/vdso-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
 
 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
                             $(call cc-ldoption, -Wl$(comma)--hash-style=both)
-SYSCFLAGS_vdso_syms.o = -r
-$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
+SYSCFLAGS_vdso_dummy.o = -r
+$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
        $(call if_changed,vdsold)
 
+quiet_cmd_vdso_sym = VDSOSYM $@
+      cmd_vdso_sym = $(LD) -r -R $(obj)/vdso-dummy.o -o $@
+
+$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o
+       $(call if_changed,vdso_sym)
 
 # strip rule for the .so file
 $(obj)/%.so: OBJCOPYFLAGS := -S
--

2.11.0

Quoted 8 lines
Quoted 1 line

I updated thin-ar branch.

Just in case, the following is my local fix-up:

- Fix incremental build
- Do not repeat "$(obj)/vsyscall-dummy.o" in the build command

All your changes here and to the other patches look good to me, thanks for the help.

Thanks,
Nick