aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Ponomarenko <andrewponomarenko@yandex.ru>2016-05-06 15:08:08 +0300
committerAndrey Ponomarenko <andrewponomarenko@yandex.ru>2016-05-06 15:08:08 +0300
commit737aef59b7ef09bb0f7e3809e5dd7883c0a27adc (patch)
tree1f3015b403b4ea4ace499ae768c9ea78de9d4f04
parentdd99c62d7d7989a2554d2aa69e63c0a61add49bc (diff)
downloadabi-compliance-checker-737aef59b7ef09bb0f7e3809e5dd7883c0a27adc.tar.gz
Improved support for OS X. Fixed identifying of non-public structure fields in C.
-rw-r--r--INSTALL17
-rw-r--r--abi-compliance-checker.pl92
2 files changed, 84 insertions, 25 deletions
diff --git a/INSTALL b/INSTALL
index abc126a..6d9bd04 100644
--- a/INSTALL
+++ b/INSTALL
@@ -32,8 +32,8 @@ Content:
1. G++ (3.0-4.7, 4.8.3, 4.9 or newer)
2. GNU Binutils (c++filt, readelf, objdump)
- 3. Perl 5 (5.8 or newer)
- 4. Ctags (5.8 or newer)
+ 3. Perl 5
+ 4. Ctags
5. ABI Dumper (0.99.15 or newer)
@@ -44,6 +44,19 @@ Content:
1. Xcode (g++, c++filt, otool, nm)
2. Ctags (5.8 or newer)
+2.1 Setup environment
+
+ 1. If /usr/bin/g++ points to clang, then please
+ specify GCC path by the -gcc-path option
+
+ 2. You can install GCC by the command:
+
+ brew install homebrew/versions/gcc49
+
+ And then specify its path:
+
+ abi-compliance-checker --gcc-path=/usr/local/bin/gcc-4.9 ...
+
3. REQUIREMENTS FOR MS WINDOWS
diff --git a/abi-compliance-checker.pl b/abi-compliance-checker.pl
index 83a3325..9cfbb24 100644
--- a/abi-compliance-checker.pl
+++ b/abi-compliance-checker.pl
@@ -10419,32 +10419,34 @@ sub isReserved($)
sub isPublic($$)
{
my ($TypePtr, $FieldPos) = @_;
+
return 0 if(not $TypePtr);
return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
- if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
- { # by name in C language
- # FIXME: add other methods to detect private members
- my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
- if($MName=~/priv|abidata|parent_object/i)
- { # C-styled private data
- return 0;
- }
- if(lc($MName) eq "abi")
- { # ABI information/reserved field
- return 0;
- }
- if(isReserved($MName))
- { # reserved fields
- return 0;
- }
- return 1;
- }
- elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
+
+ my $Access = $TypePtr->{"Memb"}{$FieldPos}{"access"};
+ if($Access eq "private")
{ # by access in C++ language
- return 1;
+ return 0;
}
- return 0;
+
+ # by name in C language
+ # TODO: add other methods to detect private members
+ my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
+ if($MName=~/priv|abidata|parent_object/i)
+ { # C-styled private data
+ return 0;
+ }
+ if(lc($MName) eq "abi")
+ { # ABI information/reserved field
+ return 0;
+ }
+ if(isReserved($MName))
+ { # reserved fields
+ return 0;
+ }
+
+ return 1;
}
sub getVTable_Real($$)
@@ -19763,8 +19765,26 @@ sub getArch_Object($)
return $Arch;
}
}
+ elsif($OStarget=~/macos/)
+ {
+ my $OtoolCmd = get_CmdPath("otool");
+ if(not $OtoolCmd) {
+ exitStatus("Not_Found", "can't find \"otool\"");
+ }
+
+ my $Cmd = $OtoolCmd." -hv -arch all \"$Path\"";
+ my $Out = qx/$Cmd/;
+
+ if($Out=~/X86_64/i) {
+ return "x86_64";
+ }
+ elsif($Out=~/X86/i) {
+ return "x86";
+ }
+ }
else
- { # macos, etc.
+ {
+ exitStatus("Error", "Not implemented yet");
# TODO
}
@@ -19896,9 +19916,26 @@ sub getArch_GCC($)
return $Cache{"getArch_GCC"}{$LibVersion};
}
+ if(not $GCC_PATH) {
+ return undef;
+ }
+
my $Arch = undef;
- if($GCC_PATH)
+ if(my $Target = get_dumpmachine($GCC_PATH))
+ {
+ if($Target=~/x86_64/) {
+ $Arch = "x86_64";
+ }
+ elsif($Target=~/i[3-6]86/) {
+ $Arch = "x86";
+ }
+ elsif($Target=~/\Aarm/i) {
+ $Arch = "arm";
+ }
+ }
+
+ if(not $Arch)
{
writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n");
@@ -21034,6 +21071,15 @@ sub detect_default_paths($)
}
}
+ if($OStarget=~/macos/)
+ {
+ my $Info = `$GCC_PATH --version`;
+
+ if($Info=~/clang/i) {
+ printMsg("WARNING", "doesn't work with clang, please install GCC instead (and select it by -gcc-path option)");
+ }
+ }
+
if($GCC_Ver)
{
my $GccTarget = get_dumpmachine($GCC_PATH);