[PATCH 3/8] add mem64_min/max control
Eric W. Biederman
ebiederm at xmission.com
Sun Nov 18 01:11:18 EST 2012
Yinghai Lu <yinghai at kernel.org> writes:
> On Sat, Nov 17, 2012 at 9:39 PM, Yinghai Lu <yinghai at kernel.org> wrote:
>> On Sat, Nov 17, 2012 at 9:35 PM, Yinghai Lu <yinghai at kernel.org> wrote:
>>> On Sat, Nov 17, 2012 at 9:20 PM, Eric W. Biederman
>>> <ebiederm at xmission.com> wrote:
>>>> Yinghai Lu <yinghai at kernel.org> writes:
>>>>> there is lots of R_X86_64_32 and R_X86_64_32S for 64bit purgatory.
>>>>> those come from global variables...could kill some by converting them static...
>>>>> but still have some global string or ro data....
>>>>> build one big file include all .S ?
>>>> For R_x86_64_32 and R_x86_64_32S the problem is that the instructions
>>>> are using absolute 32bit addresses.
>>>> It is probably overkill but we should be able to solve this with
>>>> by adding "-mcmodel=large" to the build of purgatory.
>>> it kill some...
>>> still have left.... looks they from .S
>>> yhlu at linux-siqj:~/xx/xx/utils/kexec-tools> readelf --relocs
>>> purgatory/purgatory.ro | grep R_X86_64_32
>>> 0000000005e9 00020000000b R_X86_64_32S 0000000000000000 .rodata + c0
>> looks like .S did not get that -mcmodel=large applied..
> so -mcmodel=large only work with .c, but does not have effects on .S ?
Yes it -mcmodel=large is about which instructions you generate. The
instructions used determine the relocates.
Just for playing with it the following patch modifies things so
purgatory is 64bit clean.
I don't know yet what to do with the 32bit and 16bit assembly.
diff --git a/purgatory/Makefile b/purgatory/Makefile
index ee1679c..e39adec 100644
@@ -64,6 +64,7 @@ $(PURGATORY): $(PURGATORY_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
+ $(STRIP) --strip-debug $@
@echo "PURGATORY_SRCS $(PURGATORY_SRCS)"
diff --git a/purgatory/arch/x86_64/Makefile b/purgatory/arch/x86_64/Makefile
index 22b4228..2a768c6 100644
@@ -2,7 +2,7 @@
# Purgatory x86_64
-x86_64_PURGATORY_SRCS_native = purgatory/arch/x86_64/entry64-32.S
+#x86_64_PURGATORY_SRCS_native = purgatory/arch/x86_64/entry64-32.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/entry64.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/setup-x86_64.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/stack.S
@@ -16,9 +16,11 @@ dist += purgatory/arch/x86_64/Makefile $(x86_64_PURGATORY_SRCS_native) \
# Don't add sources in i386/ to dist, as i386/Makefile adds them
-x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16.S
-x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
+#x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16.S
+#x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
x86_64_PURGATORY_SRCS += purgatory/arch/i386/crashdump_backup.c
x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c
+x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
diff --git a/purgatory/arch/x86_64/entry64.S b/purgatory/arch/x86_64/entry64.S
index 666023c..e3223b7 100644
@@ -37,9 +37,10 @@ entry64:
movl %eax, %fs
movl %eax, %gs
- movq $stack_init, %rsp
+ leaq stack_init(%rip), %rsp
pushq $0x10 /* CS */
- pushq $new_cs_exit
+ leaq new_cs_exit(%rip), %rax
+ pushq %rax
diff --git a/purgatory/arch/x86_64/setup-x86_64.S b/purgatory/arch/x86_64/setup-x86_64.S
index 74997fa..95572d8 100644
@@ -42,10 +42,10 @@ purgatory_start:
/* In 64bit mode the code segment is meaningless */
movq 0(%rsp), %rax
- movq %rax, jump_back_entry
+ movq %rax, jump_back_entry(%rip)
/* Setup a stack */
- movq $lstack_end, %rsp
+ leaq lstack_end(%rip), %rsp
/* Call the C code */
More information about the kexec