* [RFC] scripts: make extract-vmlinux support ARM vmlinuz
@ 2016-01-26 12:10 ` Roger Shimizu
0 siblings, 0 replies; 6+ messages in thread
From: Roger Shimizu @ 2016-01-26 12:10 UTC (permalink / raw)
To: Michal Marek, Russell King; +Cc: Roger Shimizu, linux-arm-kernel, linux-kbuild
vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
need to support such case.
This fix is tested on amd64 and armel platform.
Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
Dear Michal and Russell,
I'm studying ARM booting process, and happened to find scripts/extract-vmlinux
in kernel tree is broken on ARM for long time. [0][1]
[0]: https://bugs.launchpad.net/linaro-ubuntu/+bug/1050453
[1]: https://bugs.linaro.org/show_bug.cgi?id=461
The patch I created looks like dirty hack, and I don't know the status of
whether vmlinuz is ELF or not on other platforms, so I make this as "RFC".
Please comment. Thank you!
Cheers,
Roger
| 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
index 5061abcc2540..d569eb8c8efe 100755
--- a/scripts/extract-vmlinux
+++ b/scripts/extract-vmlinux
@@ -15,7 +15,15 @@ check_vmlinux()
# Use readelf to check if it's a valid ELF
# TODO: find a better to way to check that it's really vmlinux
# and not just an elf
- readelf -h $1 > /dev/null 2>&1 || return 1
+ case "$2" in
+ 0|"")
+ readelf -h $1 > /dev/null 2>&1 || return 1
+ ;;
+ 1|*)
+ # For ARCH like ARM, vmlinux is not ELF, so we only do the check
+ # when $2 is 0 or NULL
+ ;;
+ esac
cat $1
exit 0
@@ -31,7 +39,7 @@ try_decompress()
do
pos=${pos%%:*}
tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
- check_vmlinux $tmp
+ test $? -eq 0 && check_vmlinux $tmp 1
done
}
@@ -53,7 +61,7 @@ check_vmlinux $img
# That didn't work, so retry after decompression.
try_decompress '\037\213\010' xy gunzip
-try_decompress '\3757zXZ\000' abcde unxz
+try_decompress '\3757zXZ\000' abcde "unxz --single-stream"
try_decompress 'BZh' xy bunzip2
try_decompress '\135\0\0\0' xxx unlzma
try_decompress '\211\114\132' xy 'lzop -d'
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC] scripts: make extract-vmlinux support ARM vmlinuz
@ 2016-01-26 12:10 ` Roger Shimizu
0 siblings, 0 replies; 6+ messages in thread
From: Roger Shimizu @ 2016-01-26 12:10 UTC (permalink / raw)
To: linux-arm-kernel
vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
need to support such case.
This fix is tested on amd64 and armel platform.
Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
Dear Michal and Russell,
I'm studying ARM booting process, and happened to find scripts/extract-vmlinux
in kernel tree is broken on ARM for long time. [0][1]
[0]: https://bugs.launchpad.net/linaro-ubuntu/+bug/1050453
[1]: https://bugs.linaro.org/show_bug.cgi?id=461
The patch I created looks like dirty hack, and I don't know the status of
whether vmlinuz is ELF or not on other platforms, so I make this as "RFC".
Please comment. Thank you!
Cheers,
Roger
| 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
index 5061abcc2540..d569eb8c8efe 100755
--- a/scripts/extract-vmlinux
+++ b/scripts/extract-vmlinux
@@ -15,7 +15,15 @@ check_vmlinux()
# Use readelf to check if it's a valid ELF
# TODO: find a better to way to check that it's really vmlinux
# and not just an elf
- readelf -h $1 > /dev/null 2>&1 || return 1
+ case "$2" in
+ 0|"")
+ readelf -h $1 > /dev/null 2>&1 || return 1
+ ;;
+ 1|*)
+ # For ARCH like ARM, vmlinux is not ELF, so we only do the check
+ # when $2 is 0 or NULL
+ ;;
+ esac
cat $1
exit 0
@@ -31,7 +39,7 @@ try_decompress()
do
pos=${pos%%:*}
tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
- check_vmlinux $tmp
+ test $? -eq 0 && check_vmlinux $tmp 1
done
}
@@ -53,7 +61,7 @@ check_vmlinux $img
# That didn't work, so retry after decompression.
try_decompress '\037\213\010' xy gunzip
-try_decompress '\3757zXZ\000' abcde unxz
+try_decompress '\3757zXZ\000' abcde "unxz --single-stream"
try_decompress 'BZh' xy bunzip2
try_decompress '\135\0\0\0' xxx unlzma
try_decompress '\211\114\132' xy 'lzop -d'
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC] scripts: make extract-vmlinux support ARM vmlinuz
2016-01-26 12:10 ` Roger Shimizu
@ 2016-01-26 13:42 ` Russell King - ARM Linux
-1 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2016-01-26 13:42 UTC (permalink / raw)
To: Roger Shimizu; +Cc: Michal Marek, linux-arm-kernel, linux-kbuild
On Tue, Jan 26, 2016 at 09:10:36PM +0900, Roger Shimizu wrote:
> vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
> index 5061abcc2540..d569eb8c8efe 100755
> --- a/scripts/extract-vmlinux
> +++ b/scripts/extract-vmlinux
> @@ -15,7 +15,15 @@ check_vmlinux()
> # Use readelf to check if it's a valid ELF
> # TODO: find a better to way to check that it's really vmlinux
> # and not just an elf
> - readelf -h $1 > /dev/null 2>&1 || return 1
> + case "$2" in
> + 0|"")
> + readelf -h $1 > /dev/null 2>&1 || return 1
> + ;;
> + 1|*)
> + # For ARCH like ARM, vmlinux is not ELF, so we only do the check
> + # when $2 is 0 or NULL
This comment seems to be misleading - I think you mean "vmlinuz" there,
or maybe "zImage" as the file is named in the kernel build tree to make
it clear what you're referring to. "vmlinuz" is the name chosen by
distro installers.
--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC] scripts: make extract-vmlinux support ARM vmlinuz
@ 2016-01-26 13:42 ` Russell King - ARM Linux
0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2016-01-26 13:42 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 26, 2016 at 09:10:36PM +0900, Roger Shimizu wrote:
> vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
> index 5061abcc2540..d569eb8c8efe 100755
> --- a/scripts/extract-vmlinux
> +++ b/scripts/extract-vmlinux
> @@ -15,7 +15,15 @@ check_vmlinux()
> # Use readelf to check if it's a valid ELF
> # TODO: find a better to way to check that it's really vmlinux
> # and not just an elf
> - readelf -h $1 > /dev/null 2>&1 || return 1
> + case "$2" in
> + 0|"")
> + readelf -h $1 > /dev/null 2>&1 || return 1
> + ;;
> + 1|*)
> + # For ARCH like ARM, vmlinux is not ELF, so we only do the check
> + # when $2 is 0 or NULL
This comment seems to be misleading - I think you mean "vmlinuz" there,
or maybe "zImage" as the file is named in the kernel build tree to make
it clear what you're referring to. "vmlinuz" is the name chosen by
distro installers.
--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] scripts: make extract-vmlinux support ARM vmlinuz
2016-01-26 13:42 ` Russell King - ARM Linux
@ 2016-01-26 23:28 ` Roger Shimizu
-1 siblings, 0 replies; 6+ messages in thread
From: Roger Shimizu @ 2016-01-26 23:28 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: Michal Marek, linux-arm-kernel, linux-kbuild
On Tue, Jan 26, 2016 at 10:42 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jan 26, 2016 at 09:10:36PM +0900, Roger Shimizu wrote:
>> vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
>> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
>> index 5061abcc2540..d569eb8c8efe 100755
>> --- a/scripts/extract-vmlinux
>> +++ b/scripts/extract-vmlinux
>> @@ -15,7 +15,15 @@ check_vmlinux()
>> # Use readelf to check if it's a valid ELF
>> # TODO: find a better to way to check that it's really vmlinux
>> # and not just an elf
>> - readelf -h $1 > /dev/null 2>&1 || return 1
>> + case "$2" in
>> + 0|"")
>> + readelf -h $1 > /dev/null 2>&1 || return 1
>> + ;;
>> + 1|*)
>> + # For ARCH like ARM, vmlinux is not ELF, so we only do the check
>> + # when $2 is 0 or NULL
>
> This comment seems to be misleading - I think you mean "vmlinuz" there,
> or maybe "zImage" as the file is named in the kernel build tree to make
> it clear what you're referring to. "vmlinuz" is the name chosen by
> distro installers.
I just add these comment following original comment above.
And even the script name is "extract-vmlinux".
In the check_vmlinux() routine, the target of the check is
decompressed result of
parsed part zImage file.
I guess the original comment is true, it's called vmlinux in kernel build tree.
I hope you can comment:
- whether my hack work for all ARMs (armel/armhf/arm64 etc). I only
tested armel.
- whether there's better way to check ARM's vmlinux
Thank you!
Cheers,
Roger
--
Roger Shimizu, GMT +9 Tokyo
PGP/GPG: 17B3ACB1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC] scripts: make extract-vmlinux support ARM vmlinuz
@ 2016-01-26 23:28 ` Roger Shimizu
0 siblings, 0 replies; 6+ messages in thread
From: Roger Shimizu @ 2016-01-26 23:28 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 26, 2016 at 10:42 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jan 26, 2016 at 09:10:36PM +0900, Roger Shimizu wrote:
>> vmlinuz on ARM seems is not an ELF, so scripts/extract-vmlinux
>> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
>> index 5061abcc2540..d569eb8c8efe 100755
>> --- a/scripts/extract-vmlinux
>> +++ b/scripts/extract-vmlinux
>> @@ -15,7 +15,15 @@ check_vmlinux()
>> # Use readelf to check if it's a valid ELF
>> # TODO: find a better to way to check that it's really vmlinux
>> # and not just an elf
>> - readelf -h $1 > /dev/null 2>&1 || return 1
>> + case "$2" in
>> + 0|"")
>> + readelf -h $1 > /dev/null 2>&1 || return 1
>> + ;;
>> + 1|*)
>> + # For ARCH like ARM, vmlinux is not ELF, so we only do the check
>> + # when $2 is 0 or NULL
>
> This comment seems to be misleading - I think you mean "vmlinuz" there,
> or maybe "zImage" as the file is named in the kernel build tree to make
> it clear what you're referring to. "vmlinuz" is the name chosen by
> distro installers.
I just add these comment following original comment above.
And even the script name is "extract-vmlinux".
In the check_vmlinux() routine, the target of the check is
decompressed result of
parsed part zImage file.
I guess the original comment is true, it's called vmlinux in kernel build tree.
I hope you can comment:
- whether my hack work for all ARMs (armel/armhf/arm64 etc). I only
tested armel.
- whether there's better way to check ARM's vmlinux
Thank you!
Cheers,
Roger
--
Roger Shimizu, GMT +9 Tokyo
PGP/GPG: 17B3ACB1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-01-26 23:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-26 12:10 [RFC] scripts: make extract-vmlinux support ARM vmlinuz Roger Shimizu
2016-01-26 12:10 ` Roger Shimizu
2016-01-26 13:42 ` Russell King - ARM Linux
2016-01-26 13:42 ` Russell King - ARM Linux
2016-01-26 23:28 ` Roger Shimizu
2016-01-26 23:28 ` Roger Shimizu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.