[PATCHv3] arm/pie/build: do not produce relocatable parasite object

Submitted by Dmitry Safonov on April 27, 2016, 11:15 a.m.

Details

Message ID 1461755707-13872-1-git-send-email-dsafonov@virtuozzo.com
State Accepted
Series "pie/build/!piegen-y: do not produce relocatable parasite object"
Commit 4186f8d270f2d329a860f6c59cb695b281998b75
Headers show

Commit Message

Dmitry Safonov April 27, 2016, 11:15 a.m.
With `-r` option relocation to parasite_service
was not made on ARM:
0x76dbc018:	bl	0x76dbc018		0xebfffffe
(You may saw it with objdump also).

This leaded to hang at "Putting tsock" message:
(01.368297) ----------------------------------------
(01.368321)
(01.368339) Collecting fds (pid: 13503)
(01.368360) ----------------------------------------
(01.368535) Found 3 file descriptors
(01.368564) ----------------------------------------
(01.368648) Dump private signals of 13503
(01.368708) Dump shared signals of 13503
(01.368761) Parasite syscall_ip at 0x10000
(01.369605) Set up parasite blob using memfd
(01.369641) Putting parasite blob into 0x76cc5000->0x76e1f000
(01.369755) Dumping GP/FPU registers for 13503
(01.369818) Putting tsock into pid 13503

Link against native.lib.a which also fixes build for aarm64.

Reported-by: alex vk <avankemp@gmail.com>
Reported-by: long.wanglong <long.wanglong@huawei.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
---
v3: check aarch64 in ARCH instead of arm64
v2: drop partial linking only for arm/arm64

 criu/pie/Makefile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 3679e24438a4..a32047b973b9 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -153,19 +153,24 @@  $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel
 
 else # !piegen-y
 
+# ld on arm doesn't like -pie and -r options together
+ifeq ($(filter arm aarch64,$(ARCH)),)
+        LD_R := -r
+endif
+
 define gen-rule-built-in.bin.o
 $(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o		\
-				$(obj)/pie.lds-$(1).S
+				$(obj)/pie.lds-$(1).S $(obj)/native.lib.a
 	$$(call msg-gen, $$@)
-	$(Q) $(LD) -r -T $(obj)/pie.lds-$(1).S -o $$@ $$<
+	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-$(1).S -o $$@ $$< $(obj)/native.lib.a
 endef
 
 $(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
 
 $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o		\
-				$(obj)/pie.lds-native.S
+				$(obj)/pie.lds-native.S $(obj)/native.lib.a
 	$(call msg-gen, $@)
-	$(Q) $(LD) -r -T $(obj)/pie.lds-native.S -o $@ $<
+	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-native.S -o $@ $< $(obj)/native.lib.a
 
 $(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
 	$(call msg-gen, $@)

Comments

Dmitry Safonov April 27, 2016, 11:33 a.m.
On 04/27/2016 02:34 PM, Pavel Emelyanov wrote:
> What's the github issue this is related to?

#150, should have added this to commit message.
Yet, it doesn't close the issue, as there are some
other problems on aarch64.

> On 04/27/2016 02:15 PM, Dmitry Safonov wrote:
>> With `-r` option relocation to parasite_service
>> was not made on ARM:
>> 0x76dbc018:	bl	0x76dbc018		0xebfffffe
>> (You may saw it with objdump also).
>>
>> This leaded to hang at "Putting tsock" message:
>> (01.368297) ----------------------------------------
>> (01.368321)
>> (01.368339) Collecting fds (pid: 13503)
>> (01.368360) ----------------------------------------
>> (01.368535) Found 3 file descriptors
>> (01.368564) ----------------------------------------
>> (01.368648) Dump private signals of 13503
>> (01.368708) Dump shared signals of 13503
>> (01.368761) Parasite syscall_ip at 0x10000
>> (01.369605) Set up parasite blob using memfd
>> (01.369641) Putting parasite blob into 0x76cc5000->0x76e1f000
>> (01.369755) Dumping GP/FPU registers for 13503
>> (01.369818) Putting tsock into pid 13503
>>
>> Link against native.lib.a which also fixes build for aarm64.
>>
>> Reported-by: alex vk <avankemp@gmail.com>
>> Reported-by: long.wanglong <long.wanglong@huawei.com>
>> Cc: Cyrill Gorcunov <gorcunov@gmail.com>
>> Cc: Christopher Covington <cov@codeaurora.org>
>> Reviewed-by: Christopher Covington <cov@codeaurora.org>
>> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
>> ---
>> v3: check aarch64 in ARCH instead of arm64
>> v2: drop partial linking only for arm/arm64
>>
>>   criu/pie/Makefile | 13 +++++++++----
>>   1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/criu/pie/Makefile b/criu/pie/Makefile
>> index 3679e24438a4..a32047b973b9 100644
>> --- a/criu/pie/Makefile
>> +++ b/criu/pie/Makefile
>> @@ -153,19 +153,24 @@ $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel
>>   
>>   else # !piegen-y
>>   
>> +# ld on arm doesn't like -pie and -r options together
>> +ifeq ($(filter arm aarch64,$(ARCH)),)
>> +        LD_R := -r
>> +endif
>> +
>>   define gen-rule-built-in.bin.o
>>   $(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o		\
>> -				$(obj)/pie.lds-$(1).S
>> +				$(obj)/pie.lds-$(1).S $(obj)/native.lib.a
>>   	$$(call msg-gen, $$@)
>> -	$(Q) $(LD) -r -T $(obj)/pie.lds-$(1).S -o $$@ $$<
>> +	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-$(1).S -o $$@ $$< $(obj)/native.lib.a
>>   endef
>>   
>>   $(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
>>   
>>   $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o		\
>> -				$(obj)/pie.lds-native.S
>> +				$(obj)/pie.lds-native.S $(obj)/native.lib.a
>>   	$(call msg-gen, $@)
>> -	$(Q) $(LD) -r -T $(obj)/pie.lds-native.S -o $@ $<
>> +	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-native.S -o $@ $< $(obj)/native.lib.a
>>   
>>   $(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
>>   	$(call msg-gen, $@)
>>
Pavel Emelianov April 27, 2016, 11:34 a.m.
What's the github issue this is related to?

On 04/27/2016 02:15 PM, Dmitry Safonov wrote:
> With `-r` option relocation to parasite_service
> was not made on ARM:
> 0x76dbc018:	bl	0x76dbc018		0xebfffffe
> (You may saw it with objdump also).
> 
> This leaded to hang at "Putting tsock" message:
> (01.368297) ----------------------------------------
> (01.368321)
> (01.368339) Collecting fds (pid: 13503)
> (01.368360) ----------------------------------------
> (01.368535) Found 3 file descriptors
> (01.368564) ----------------------------------------
> (01.368648) Dump private signals of 13503
> (01.368708) Dump shared signals of 13503
> (01.368761) Parasite syscall_ip at 0x10000
> (01.369605) Set up parasite blob using memfd
> (01.369641) Putting parasite blob into 0x76cc5000->0x76e1f000
> (01.369755) Dumping GP/FPU registers for 13503
> (01.369818) Putting tsock into pid 13503
> 
> Link against native.lib.a which also fixes build for aarm64.
> 
> Reported-by: alex vk <avankemp@gmail.com>
> Reported-by: long.wanglong <long.wanglong@huawei.com>
> Cc: Cyrill Gorcunov <gorcunov@gmail.com>
> Cc: Christopher Covington <cov@codeaurora.org>
> Reviewed-by: Christopher Covington <cov@codeaurora.org>
> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> ---
> v3: check aarch64 in ARCH instead of arm64
> v2: drop partial linking only for arm/arm64
> 
>  criu/pie/Makefile | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/criu/pie/Makefile b/criu/pie/Makefile
> index 3679e24438a4..a32047b973b9 100644
> --- a/criu/pie/Makefile
> +++ b/criu/pie/Makefile
> @@ -153,19 +153,24 @@ $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel
>  
>  else # !piegen-y
>  
> +# ld on arm doesn't like -pie and -r options together
> +ifeq ($(filter arm aarch64,$(ARCH)),)
> +        LD_R := -r
> +endif
> +
>  define gen-rule-built-in.bin.o
>  $(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o		\
> -				$(obj)/pie.lds-$(1).S
> +				$(obj)/pie.lds-$(1).S $(obj)/native.lib.a
>  	$$(call msg-gen, $$@)
> -	$(Q) $(LD) -r -T $(obj)/pie.lds-$(1).S -o $$@ $$<
> +	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-$(1).S -o $$@ $$< $(obj)/native.lib.a
>  endef
>  
>  $(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
>  
>  $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o		\
> -				$(obj)/pie.lds-native.S
> +				$(obj)/pie.lds-native.S $(obj)/native.lib.a
>  	$(call msg-gen, $@)
> -	$(Q) $(LD) -r -T $(obj)/pie.lds-native.S -o $@ $<
> +	$(Q) $(LD) $(LD_R) -T $(obj)/pie.lds-native.S -o $@ $< $(obj)/native.lib.a
>  
>  $(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
>  	$(call msg-gen, $@)
>
Cyrill Gorcunov April 27, 2016, 11:50 a.m.
On Wed, Apr 27, 2016 at 02:15:07PM +0300, Dmitry Safonov wrote:
> With `-r` option relocation to parasite_service
> was not made on ARM:
> 0x76dbc018:	bl	0x76dbc018		0xebfffffe
> (You may saw it with objdump also).
> 
...
> Link against native.lib.a which also fixes build for aarm64.
> 
> Reported-by: alex vk <avankemp@gmail.com>
> Reported-by: long.wanglong <long.wanglong@huawei.com>
> Cc: Cyrill Gorcunov <gorcunov@gmail.com>
> Cc: Christopher Covington <cov@codeaurora.org>
> Reviewed-by: Christopher Covington <cov@codeaurora.org>
> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Pavel Emelianov May 4, 2016, 7:17 a.m.
Applied. thanks