/usr/bin/titanver is in eclipse-titan 6.3.1-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | #!/bin/sh
###############################################################################
# Copyright (c) 2000-2017 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
###############################################################################
# Find Perl in the path
# Can't use `perl -e 'print $^X'` because that may print just "perl"
perlexe=`which perl 2>/dev/null | sed -n 's/[^\/]*\(\/.*perl\)/\1/p'`
# Do it the hard way if not found
if [ -z "${perlexe}" ] ; then
GCCVER=`strings -a -10 ${1+"$@"} | sed -n '
s/.*TITAN: [0-9][0-9]* PLATFORM: [A-Z0-9][A-Z0-9]* //
/GCC: (GNU)/ {
p
}
s/.*TITAN: [0-9][0-9]* PLATFORM: [A-Z0-9][A-Z0-9]* //
/Clang: (GNU)/ {
p
}
/Sun C++/ {
s/.*\(Sun C++ *[0-9]\.[0-9]\).*/\1/g
p
}
' | sort -u`;
if [ `echo "${GCCVER}" | wc -l` != 1 ]; then
echo -e "Error! Object files compiled with different compilers were detected:
${GCCVER}
Please clean and rebuild your project.";
exit 1;
else
: ; # no news is good news
fi
exit 0; # avoid flowing into Perl
fi
#! Here begins the real -*- perl -*- -ws
#line 34
# The above directive should be adjusted to the line number of ** this ** line
eval 'exec ${perlexe} -x $0 ${1+"$@"} ;'
if 0;
use strict;
use vars qw($r $v);
my $compiler = 'Compiler';
my %versions;
my $objdump = `/bin/sh -c "which objdump" 2>/dev/null`;
chomp $objdump;
exit 0 if ($objdump !~ m!^/! or !@ARGV); # go quiet if no objdump or @ARGV is empty
my $comment = '';
my @sections = qw( .titan .comment );
my $found_ver;
my $cmdline;
open (PIPE, $cmdline = "$objdump -s -j " . join(' -j ', @sections) . " @ARGV |") or die "open failed: $!";
my $obj = '?';
sub match_comment() {
if (length($comment)) {
($found_ver) = $comment =~ /((GCC|Clang): \([^)]*\) \d\.\d+(?:\.\d+)?)/;
if ($found_ver) {
print "$compiler version was $found_ver for $obj\n" if $v;
push @{$versions{$found_ver}}, $obj;
if (defined $r and $r ne $found_ver) {
if (!$v) { # found version was not written, do it now
warn "$compiler was $found_ver for $obj\n";
}
die " $r was expected\n";
}
}
}
}
while (<PIPE>)
{
chomp;
next unless length;
if (/^([^:]+):\s+file format/) {
match_comment();
$obj = $1;
$comment = '';
}
elsif (my ($text) =
m/^ \s*
\d{4,} # offset
\s
[0-9a-fA-F ]{8} # first group of hex digits
\s
[0-9a-fA-F ]{8} # these should be [[:xdigit:] ] but rhea's perl is ancient :(
\s
[0-9a-fA-F ]{8}
\s
[0-9a-fA-F ]{8}
\s\s
(.+) # up to 16 characters of "plain" text
$/x) {
$comment .= $text;
}
}
match_comment();
close (PIPE) or die "close failed: $!";
if ( scalar keys %versions > 1 ) {
while ( my ($ver, $ref) = each %versions ) {
warn "Compiled with $compiler $ver: ", join(', ', @$ref), "\n";
}
die "Error! All object files should be compiled with the same compiler version.\n"
. "The following $compiler versions were detected: ", join(', ', keys %versions),
"\nRun make clean and make to recompile the project if the version of the compiler changed recently.";
}
__END__
Parse the output of objdump, which looks like this:
core/XmlReader.o: file format elf64-x86-64
Contents of section .comment:
0000 00474343 3a202847 4e552920 342e342e .GCC: (GNU) 4.4.
0010 30203230 30393032 31332028 65787065 0 20090213 (expe
0020 72696d65 6e74616c 2900 rimental).
Options:
-r=x.x.x expected GCC version
-v verbose
Error conditions:
** -r=XXX supplied and one of the objects fail to match
** more than one GCC version detected
|