Skip to contentSkip to conversation

out out damn perl

PATCH In review Rob Landley 9 participants 12 messages Jan 6, 2015 – Jan 17, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 out out damn perl

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

---

 arch/x86/boot/compressed/Makefile |    6 ++--
 arch/x86/tools/calc_run_size.pl   |   39 ----------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

Commit e6023367d779 added perl back to the kernel build. KILL IT WITH FIRE.

arch/x86/boot/compressed/Makefile +4 -2
@@ -89,8 +76,10 @@
 suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
 suffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
 
-RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
-	     perl $(srctree)/arch/x86/tools/calc_run_size.pl)
+RUN_SIZE = $(shell NUM='\([0-9a-fA-F]*[ \t]*\)'; $(OBJDUMP) -h vmlinux | \
+sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"$$NUM$$NUM$$NUM$$NUM"'.*/\1\4/p' | \
+xargs | while read a b c d; do [ "$$b" != "$$d" ] && exit 1; \
+expr $$(printf "%d + %d + %d" 0x$$a 0x$$b 0x$$c); done)
 quiet_cmd_mkpiggy = MKPIGGY $@
       cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
 
arch/x86/tools/calc_run_size.pl deleted +0 -39
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-#
-# Calculate the amount of space needed to run the kernel, including room for
-# the .bss and .brk sections.
-#
-# Usage:
-# objdump -h a.out | perl calc_run_size.pl
-use strict;
-
-my $mem_size = 0;
-my $file_offset = 0;
-
-my $sections=" *[0-9]+ \.(?:bss|brk) +";
-while (<>) {
-	if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
-		my $size = hex($1);
-		my $offset = hex($2);
-		$mem_size += $size;
-		if ($file_offset == 0) {
-			$file_offset = $offset;
-		} elsif ($file_offset != $offset) {
-			# BFD linker shows the same file offset in ELF.
-			# Gold linker shows them as consecutive.
-			next if ($file_offset + $mem_size == $offset + $size);
-
-			printf STDERR "file_offset: 0x%lx\n", $file_offset;
-			printf STDERR "mem_size: 0x%lx\n", $mem_size;
-			printf STDERR "offset: 0x%lx\n", $offset;
-			printf STDERR "size: 0x%lx\n", $size;
-
-			die ".bss and .brk are non-contiguous\n";
-		}
-	}
-}
-
-if ($file_offset == 0) {
-	die "Never found .bss or .brk file offset\n";
-}
-printf("%d\n", $mem_size + $file_offset);
#1 lore raw
Quoted 2 lines · On Tue, 06 Jan 2015 17:41:35 -0600 Rob Landley <[email protected]> wrote:

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Please resend this:

- Express the commit in the conventional fashion

e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd")

- So that we all don't have to go look up the commit to find out what happened.

- So people can look up the commit in other trees, where the hash might change.

- Cc the people who wrote and committed the patch.

- The offending commit has cc:stable, so have a think about adding a cc:stable to this one as well.

- The title is cute, but not terribly informative.

#2 lore raw

PATCH v2 1/1 remove recently added perl build requirement

From: Rob Landley <[email protected]>

Commit e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") added perl back to the kernel build dependencies in -rc6.

Replace those 39 lines of perl with 4 lines of shell script.

---

 arch/x86/boot/compressed/Makefile |    6 ++--
 arch/x86/tools/calc_run_size.pl   |   39 ----------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

Note: checkpatch.pl isn't a build dependency, it's a development dependency (like bloat-o-meter being written in python or "make xconfig" needing QT). Those aren't things you need to add to your cross compile environment to produce a binary. Different category of dependency.

For more history on the issue, see https://lkml.org/lkml/2013/2/27/18

arch/x86/boot/compressed/Makefile +4 -2
@@ -89,8 +76,10 @@
 suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
 suffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
 
-RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
-	     perl $(srctree)/arch/x86/tools/calc_run_size.pl)
+RUN_SIZE = $(shell NUM='\([0-9a-fA-F]*[ \t]*\)'; $(OBJDUMP) -h vmlinux | \
+sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"$$NUM$$NUM$$NUM$$NUM"'.*/\1\4/p' | \
+xargs | while read a b c d; do [ "$$b" != "$$d" ] && exit 1; \
+expr $$(printf "%d + %d + %d" 0x$$a 0x$$b 0x$$c); done)
 quiet_cmd_mkpiggy = MKPIGGY $@
       cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
 
arch/x86/tools/calc_run_size.pl deleted +0 -39
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-#
-# Calculate the amount of space needed to run the kernel, including room for
-# the .bss and .brk sections.
-#
-# Usage:
-# objdump -h a.out | perl calc_run_size.pl
-use strict;
-
-my $mem_size = 0;
-my $file_offset = 0;
-
-my $sections=" *[0-9]+ \.(?:bss|brk) +";
-while (<>) {
-	if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
-		my $size = hex($1);
-		my $offset = hex($2);
-		$mem_size += $size;
-		if ($file_offset == 0) {
-			$file_offset = $offset;
-		} elsif ($file_offset != $offset) {
-			# BFD linker shows the same file offset in ELF.
-			# Gold linker shows them as consecutive.
-			next if ($file_offset + $mem_size == $offset + $size);
-
-			printf STDERR "file_offset: 0x%lx\n", $file_offset;
-			printf STDERR "mem_size: 0x%lx\n", $mem_size;
-			printf STDERR "offset: 0x%lx\n", $offset;
-			printf STDERR "size: 0x%lx\n", $size;
-
-			die ".bss and .brk are non-contiguous\n";
-		}
-	}
-}
-
-if ($file_offset == 0) {
-	die "Never found .bss or .brk file offset\n";
-}
-printf("%d\n", $mem_size + $file_offset);
#3 lore raw

Re: [PATCHv2] remove recently added perl build requirement

Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") added perl back to the kernel build dependencies in -rc6.

Ah, yeah, good call on Perl as a build dep.

Quoted 21 lines

Replace those 39 lines of perl with 4 lines of shell script.

---

 arch/x86/boot/compressed/Makefile |    6 ++--
 arch/x86/tools/calc_run_size.pl   |   39 ----------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

Note: checkpatch.pl isn't a build dependency, it's a development dependency (like bloat-o-meter being written in python or "make xconfig" needing QT). Those aren't things you need to add to your cross compile environment to produce a binary. Different category of dependency.

For more history on the issue, see https://lkml.org/lkml/2013/2/27/18

arch/x86/boot/compressed/Makefile +0 -0
@@ -89,8 +76,10 @@
 suffix-$(CONFIG_KERNEL_LZO)    := lzo

arch/x86/boot/compressed/Makefile line 84

Quoted 10 lines
arch/x86/boot/compressed/Makefile +4 -2
 suffix-$(CONFIG_KERNEL_LZ4)    := lz4
 
-RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
-            perl $(srctree)/arch/x86/tools/calc_run_size.pl)
+RUN_SIZE = $(shell NUM='\([0-9a-fA-F]*[ \t]*\)'; $(OBJDUMP) -h vmlinux | \
+sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"$$NUM$$NUM$$NUM$$NUM"'.*/\1\4/p' | \
+xargs | while read a b c d; do [ "$$b" != "$$d" ] && exit 1; \
+expr $$(printf "%d + %d + %d" 0x$$a 0x$$b 0x$$c); done)
 quiet_cmd_mkpiggy = MKPIGGY $@
       cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )

I'd much prefer a full shell script as this is hard to read. It loses all the comments and variable names, etc. Also, this reverts commit 70b61e362187 ("x86, kaslr: Handle Gold linker for finding bss/brk").

-Kees

Quoted 43 lines
arch/x86/tools/calc_run_size.pl deleted +0 -39
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-#
-# Calculate the amount of space needed to run the kernel, including room for
-# the .bss and .brk sections.
-#
-# Usage:
-# objdump -h a.out | perl calc_run_size.pl
-use strict;
-
-my $mem_size = 0;
-my $file_offset = 0;
-
-my $sections=" *[0-9]+ \.(?:bss|brk) +";
-while (<>) {
-       if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
-               my $size = hex($1);
-               my $offset = hex($2);
-               $mem_size += $size;
-               if ($file_offset == 0) {
-                       $file_offset = $offset;
-               } elsif ($file_offset != $offset) {
-                       # BFD linker shows the same file offset in ELF.
-                       # Gold linker shows them as consecutive.
-                       next if ($file_offset + $mem_size == $offset + $size);
-
-                       printf STDERR "file_offset: 0x%lx\n", $file_offset;
-                       printf STDERR "mem_size: 0x%lx\n", $mem_size;
-                       printf STDERR "offset: 0x%lx\n", $offset;
-                       printf STDERR "size: 0x%lx\n", $size;
-
-                       die ".bss and .brk are non-contiguous\n";
-               }
-       }
-}
-
-if ($file_offset == 0) {
-       die "Never found .bss or .brk file offset\n";
-}
-printf("%d\n", $mem_size + $file_offset);
Signature · 2 lines
Kees Cook
Chrome OS Security
#4 lore raw
In reply to Andrew Morton
Quoted 14 lines · Andrew Morton
Quoted 2 lines · On Tue, 06 Jan 2015 17:41:35 -0600 Rob Landley <[email protected]> wrote:

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Please resend this:

- Express the commit in the conventional fashion

e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd")

- So that we all don't have to go look up the commit to find out what happened.

Quoted 7 lines

- So people can look up the commit in other trees, where the hash might change.

- Cc the people who wrote and committed the patch.

- The offending commit has cc:stable, so have a think about adding a cc:stable to this one as well.

Actually, I don't think this should go to stable. I like the patch, but it is not a bug, and certainly not serious enough one.

Quoted 1 line

- The title is cute, but not terribly informative.

Cute :-).

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Andrew Morton
Quoted 2 lines · On Tue, 06 Jan 2015 17:41:35 -0600 Rob Landley <[email protected]> wrote:

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Please resend this:

- Express the commit in the conventional fashion

e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd")

- So that we all don't have to go look up the commit to find out what happened.

- So people can look up the commit in other trees, where the hash might change.

Quoted 7 lines
Quoted 4 lines

- Cc the people who wrote and committed the patch.

- The offending commit has cc:stable, so have a think about adding a cc:stable to this one as well.

Actually, I don't think this should go to stable. I like the patch, but it is not a bug, and certainly not serious enough one.

It is a regression w.r.t. building.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw
In reply to Pavel Machek
Quoted 6 lines · Pavel Machek
Quoted 4 lines · Andrew Morton
Quoted 2 lines · On Tue, 06 Jan 2015 17:41:35 -0600 Rob Landley <[email protected]> wrote:

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

...

Quoted 5 lines
Quoted 2 lines

- The offending commit has cc:stable, so have a think about adding a cc:stable to this one as well.

Actually, I don't think this should go to stable. I like the patch, but it is not a bug, and certainly not serious enough one.

As long as the kernel doesn't make a habit of it, I don't care if there's a release or two embedded developers should skip. Under ideal conditions BSPs only tend to update about once every 18 months, and that's the _good_ ones.

Rob

#7 lore raw
In reply to Rob Landley
Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Maybe checkpatch should be updated to look for perl. :)

Signature · 1 line
Len Sorensen
maintainer
#8 lore raw
Quoted 7 lines · Lennart Sorensen
Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Maybe checkpatch should be updated to look for perl. :)

And patch itself out. Yep, good idea. :-D

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#9 lore raw
In reply to Lennart Sorensen
Quoted 7 lines · Lennart Sorensen
Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Maybe checkpatch should be updated to look for perl. :)

Yeah, then checkpatch.pl warn on itself. ;-)

Signature · 2 lines
Thanks,
//richard
#10 lore raw
Quoted 11 lines · Richard Weinberger
Quoted 7 lines · Lennart Sorensen
Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Maybe checkpatch should be updated to look for perl. :)

Yeah, then checkpatch.pl warn on itself. ;-)

There's a difference between a development tool and a build tool. We have "make xconfig" and "make gconfig" but don't require qt and gtk to both be in your cross compile environment in order to build the kernel.

Rob

#11 lore raw

Am 12.01.2015 um 17:14 schrieb Rob Landley:

Quoted 9 lines · Richard Weinberger
Quoted 8 lines
Quoted 6 lines · Lennart Sorensen
Quoted 4 lines · Rob Landley

From: Rob Landley <[email protected]>

Commit e6023367d779 added perl back to the kernel build in -rc6. Replace 39 lines of perl with 4 lines of shell script.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Maybe checkpatch should be updated to look for perl. :)

Yeah, then checkpatch.pl warn on itself. ;-)

There's a difference between a development tool and a build tool. We have "make xconfig" and "make gconfig" but don't require qt and gtk to both be in your cross compile environment in order to build the kernel.

You got me wrong. I'm all for removing perl as build dependency.

Thanks,
//richard