pie/build/!piegen-y: do not produce relocatable parasite object

Submitted by Dmitry Safonov on April 21, 2016, 2:34 p.m.

Details

Message ID 1461249281-32721-1-git-send-email-dsafonov@virtuozzo.com
State Rejected
Series "pie/build/!piegen-y: do not produce relocatable parasite object"
Headers show

Patch hide | download patch | download mbox

diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 3679e24438a4..b6ffb491895a 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -155,17 +155,17 @@  else # !piegen-y
 
 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) -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) -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 21, 2016, 2:48 p.m.
On 04/21/2016 05:39 PM, Cyrill Gorcunov wrote:
> On Thu, Apr 21, 2016 at 05:34:41PM +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).
>>
>> 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
>>
>> Also link against native.lib.a
>>
>> Reported-by: alex vk <avankemp@gmail.com>
>> Reported-by: long.wanglong <long.wanglong@huawei.com>
>> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> Wait. I don;t get it. -r option stands to generate relocatable
> file, why it doesn't work? Some arm specifics?

I'm not really sure, but with it ld on rpi2 doesn't do relocs here:

> [root@rpi2-jd criu]# objdump -dS criu/pie/parasite.built-in.bin.o | 
> head -n 15
> criu/pie/parasite.built-in.bin.o:     file format elf32-littlearm
> Disassembly of section .crblob:
> 00000000 <__export_parasite_head_start>:
>        0:    e24f2008     sub    r2, pc, #8
>        4:    e28f0018     add    r0, pc, #24
>        8:    e5900000     ldr    r0, [r0]
>        c:    e28f100c     add    r1, pc, #12
>       10:    e5911000     ldr    r1, [r1]
>       14:    e0811002     add    r1, r1, r2
>       18:    ebfffffe     bl    138c <parasite_service>
>       1c:    e7f001f0     .word    0xe7f001f0

And without it all goes ok.
Cyrill Gorcunov April 21, 2016, 2:51 p.m.
On Thu, Apr 21, 2016 at 05:48:16PM +0300, Dmitry Safonov wrote:
> >>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
> >>
> >>Also link against native.lib.a

This option should arm specific only. If I'm not missing
something obvious your patch affects x86 building procedure,
no?
Dmitry Safonov April 21, 2016, 2:53 p.m.
On 04/21/2016 05:51 PM, Cyrill Gorcunov wrote:
> On Thu, Apr 21, 2016 at 05:48:16PM +0300, Dmitry Safonov wrote:
>>>> 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
>>>>
>>>> Also link against native.lib.a
> This option should arm specific only. If I'm not missing
> something obvious your patch affects x86 building procedure,
> no?
It's for $(piegen-y)=n, but you right, I will add ifdefs around it.
Dmitry Safonov April 21, 2016, 3:44 p.m.
On 04/21/2016 05:39 PM, Cyrill Gorcunov wrote:
> On Thu, Apr 21, 2016 at 05:34:41PM +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).
>>
>> 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
>>
>> Also link against native.lib.a
>>
>> Reported-by: alex vk <avankemp@gmail.com>
>> Reported-by: long.wanglong <long.wanglong@huawei.com>
>> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> Wait. I don;t get it. -r option stands to generate relocatable
> file, why it doesn't work? Some arm specifics?

I'm not sure, again, but maybe it's the same as uboot had
with both -pie and -r:
http://lists.denx.de/pipermail/u-boot/2011-January/086349.html
(not really sure, but looks alike)
Cyrill Gorcunov April 21, 2016, 3:54 p.m.
On Thu, Apr 21, 2016 at 06:44:13PM +0300, Dmitry Safonov wrote:
> >Wait. I don;t get it. -r option stands to generate relocatable
> >file, why it doesn't work? Some arm specifics?
> 
> I'm not sure, again, but maybe it's the same as uboot had
> with both -pie and -r:
> http://lists.denx.de/pipermail/u-boot/2011-January/086349.html
> (not really sure, but looks alike)

Looks like indeed.