Lintian check for OCaml custom bytecode executables
tags 498138 + patch
thanks
Hello,
I've implemented this check in the attached patch.
Cheers,
--
Stéphane
>From 21c7b134f81490a13503aeffcf553f46817e7437 Mon Sep 17 00:00:00 2001
From: Stephane Glondu <steph@glondu.net>
Date: Sun, 19 Jul 2009 11:23:40 +0200
Subject: [PATCH] Add check for ocaml-custom-executable (Closes: #498138)
Remove also the previous check based on ELF symbols (but not working)
that was supposed to remove the error unstripped-binary-or-object for
such files. To summarize, this patch turns the
unstripped-binary-or-object tags into ocaml-custom-executable warnings
for OCaml custom bytecode executables.
---
checks/binaries | 24 +++++++++++++++---------
checks/binaries.desc | 8 ++++++++
lib/Lintian/Collect/Binary.pm | 4 ----
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/checks/binaries b/checks/binaries
index 83fb858..f13fcc0 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -228,14 +228,23 @@ foreach my $file (sort keys %{$info->file_info}) {
}
}
+ my $strings = slurp_entire_file("strings/$file");
+ spelling_check('spelling-error-in-binary', $strings, $file);
+
# stripped?
if ($fileinfo =~ m,not stripped\s*$,o) {
- # Is it an object file (which generally can not be stripped),
- # a kernel module, debugging symbols, or perhaps a debugging package?
- # Ocaml executables are exempted, see #252695
- unless ($file =~ m,\.k?o$, or $pkg =~ m/-dbg$/ or $pkg =~ m/debug/
- or $file =~ m,/lib/debug/, or exists $objdump->{OCAML}) {
- tag "unstripped-binary-or-object", "$file";
+ if ($strings =~ m/^Caml1999X0[0-9][0-9]$/m) {
+ # Check for OCaml custom executables (#498138)
+ if ($fileinfo =~ m/executable/) {
+ tag "ocaml-custom-executable", $file;
+ }
+ } else {
+ # Is it an object file (which generally can not be stripped),
+ # a kernel module, debugging symbols, or perhaps a debugging package?
+ unless ($file =~ m,\.k?o$, or $pkg =~ m/-dbg$/ or $pkg =~ m/debug/
+ or $file =~ m,/lib/debug/,) {
+ tag "unstripped-binary-or-object", "$file";
+ }
}
} else {
# stripped but a debug or profiling library?
@@ -262,9 +271,6 @@ foreach my $file (sort keys %{$info->file_info}) {
}
}
- my $strings = slurp_entire_file("strings/$file");
- spelling_check('spelling-error-in-binary', $strings, $file);
-
if ($pkg !~ m/^zlib.+/
and $strings =~ /(?:in|de)flate (?:\d[ \w.\-]{1,20}[\w.\-])/m) {
tag "embedded-zlib", $file;
diff --git a/checks/binaries.desc b/checks/binaries.desc
index 3cd3569..2322b9a 100644
--- a/checks/binaries.desc
+++ b/checks/binaries.desc
@@ -257,3 +257,11 @@ Info: The given debugging symbols-only object is installed directly in
<tt>/usr/bin</tt> should be placed in <tt>/usr/lib/debug/usr/bin</tt>.
gdb, when looking for debugging symbols, prepends <tt>/usr/lib/debug</tt>
to the path of the original binary.
+
+Tag: ocaml-custom-executable
+Severity: normal
+Certainty: possible
+Info: This package provides an OCaml bytecode executable linked with a
+ custom runtime. Such executables cannot be stripped and require
+ special care. Their usage is deprecated in favour of shared libraries
+ for C stubs (dll*.so).
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index fbfe053..1661d41 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -204,10 +204,6 @@ sub objdump_info {
if (m/^[0-9a-fA-F]+.{6}\w\w?\s+(\S+)\s+[0-9a-zA-Z]+\s+(\S+)\s+(\S+)$/){
my ($foo, $sec, $sym) = ($1, $2, $3);
push @{$file->{SYMBOLS}}, [ $foo, $sec, $sym ];
-
- if ($foo eq '.text' and $sec eq 'Base' and $sym eq 'caml_main') {
- $file->{OCAML} = 1;
- }
}
} else {
if (m/^\s*NEEDED\s*(\S+)/o) {
--
1.6.3.3
Reply to: