Re: [PATCH v2] MIPS: Set ISA bit in entry-y for microMIPS kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 21, 2017 at 09:20:38PM +0100, Maciej W. Rozycki wrote:
> In order to fetch the correct entry point with the ISA bit included, for 
> use by non-ELF boot loaders, parse the output of `objdump -f' for the 
> start address recorded in the kernel executable itself, rather than 
> using `nm' to get the value of the `kernel_entry' symbol.
> 
> Sign-extend the address retrieved if 32-bit, so that execution is 
> correctly started on 64-bit processors as well.  The tool always prints 
> the entry point using either 8 or 16 hexadecimal digits, matching the 
> address width (aka class) of the ELF file, even in the presence of 
> leading zeros.
> 
> Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
> ---
> Ralf,
> 
>  As you requested, here's v2 rebased as a replacement for 5fc9484f5e41,
> with the heading reused.
> 
>  Please apply.
> 
>   Maciej
> 
> ---
>  arch/mips/Makefile |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> linux-mips-start-address.diff
> Index: linux-sfr-usead/arch/mips/Makefile
> ===================================================================
> --- linux-sfr-usead.orig/arch/mips/Makefile	2017-08-21 20:48:38.000000000 +0100
> +++ linux-sfr-usead/arch/mips/Makefile	2017-08-21 17:47:16.802753000 +0100
> @@ -243,8 +243,12 @@ include arch/mips/Kbuild.platforms
>  ifdef CONFIG_PHYSICAL_START
>  load-y					= $(CONFIG_PHYSICAL_START)
>  endif
> -entry-y				= 0x$(shell $(NM) vmlinux 2>/dev/null \
> -					| grep "\bkernel_entry\b" | cut -f1 -d \ )
> +
> +# Sign-extend the entry point to 64 bits if retrieved as a 32-bit number.
> +entry-y		= $(shell $(OBJDUMP) -f vmlinux 2>/dev/null \
> +			| sed -n '/^start address / { \
> +				s/^.*0x\([0-7].......\)$$/0x00000000\1/; \
> +				s/^.*0x\(........\)$$/0xffffffff\1/; p }')

This leaves the "start address " on the beginning if the address is
already 64 bits wide, e.g.:

VMLINUX_LOAD_ADDRESS=0xffffffff80100000 VMLINUX_ENTRY_ADDRESS=start address 0xffffffff80832720 ...

The following seems to work, to drop the "start address " first then
work purely on the hex value (i.e. no need for .* at the front of the
sign extension regexes any more):

+entry-y		= $(shell $(OBJDUMP) -f vmlinux 2>/dev/null \
+			| sed -n '/^start address / { \
+				s/^.* //; \
+				s/^0x\([0-7].......\)$$/0x00000000\1/; \
+				s/^0x\(........\)$$/0xffffffff\1/; p }')

Look reasonable? Is there a cleaner way?

Cheers
James

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux