Merge "Copy sdk-classes.jar to classes-header.jar for turbine."
diff --git a/vndk/tools/definition-tool/tests/test_elf.py b/vndk/tools/definition-tool/tests/test_elf.py
index 0d25370..bb969ed 100755
--- a/vndk/tools/definition-tool/tests/test_elf.py
+++ b/vndk/tools/definition-tool/tests/test_elf.py
@@ -115,6 +115,11 @@
self.assertEqual('EI_CLASS\t32\n'
'EI_DATA\t\tLittle-Endian\n'
'E_MACHINE\tEM_AARCH64\n'
+ 'FILE_SIZE\t0\n'
+ 'RO_SEG_FILE_SIZE\t0\n'
+ 'RO_SEG_MEM_SIZE\t0\n'
+ 'RW_SEG_FILE_SIZE\t0\n'
+ 'RW_SEG_MEM_SIZE\t0\n'
'DT_RPATH\ta\n'
'DT_RUNPATH\tb\n'
'DT_NEEDED\tlibc.so\n'
@@ -129,6 +134,11 @@
data = ('EI_CLASS\t64\n'
'EI_DATA\t\tLittle-Endian\n'
'E_MACHINE\tEM_AARCH64\n'
+ 'FILE_SIZE\t90\n'
+ 'RO_SEG_FILE_SIZE\t18\n'
+ 'RO_SEG_MEM_SIZE\t24\n'
+ 'RW_SEG_FILE_SIZE\t42\n'
+ 'RW_SEG_MEM_SIZE\t81\n'
'DT_RPATH\trpath_1\n'
'DT_RPATH\trpath_2\n'
'DT_RUNPATH\trunpath_1\n'
@@ -144,6 +154,11 @@
self.assertEqual(ELF.ELFCLASS64, res.ei_class)
self.assertEqual(ELF.ELFDATA2LSB, res.ei_data)
self.assertEqual(183, res.e_machine)
+ self.assertEqual(90, res.file_size)
+ self.assertEqual(18, res.ro_seg_file_size)
+ self.assertEqual(24, res.ro_seg_mem_size)
+ self.assertEqual(42, res.rw_seg_file_size)
+ self.assertEqual(81, res.rw_seg_mem_size)
self.assertEqual(['rpath_1', 'rpath_2'], res.dt_rpath)
self.assertEqual(['runpath_1', 'runpath_2'], res.dt_runpath)
self.assertEqual(['libc.so', 'libm.so'], res.dt_needed)
diff --git a/vndk/tools/definition-tool/tests/test_elfdump.py b/vndk/tools/definition-tool/tests/test_elfdump.py
index b8e3c1e..2c0b230 100755
--- a/vndk/tools/definition-tool/tests/test_elfdump.py
+++ b/vndk/tools/definition-tool/tests/test_elfdump.py
@@ -6,6 +6,7 @@
import collections
import difflib
import os
+import re
import subprocess
import sys
import unittest
@@ -96,12 +97,25 @@
['-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
'-Wl,--enable-new-dtags'])
+ def _remove_size_lines(self, lines):
+ """Remove file size information because they may vary."""
+ prefixes = (
+ 'FILE_SIZE\t',
+ 'RO_SEG_FILE_SIZE\t',
+ 'RO_SEG_MEM_SIZE\t',
+ 'RW_SEG_FILE_SIZE\t',
+ 'RW_SEG_MEM_SIZE\t',
+ )
+ patt = re.compile('|'.join('(?:' + re.escape(x) +')' for x in prefixes))
+ return [line for line in lines if not patt.match(line)]
+
def _assert_equal_to_file(self, expected_file_name, actual):
actual = actual.splitlines(True)
expected_file_path = os.path.join(self.expected_dir, expected_file_name)
with open(expected_file_path, 'r') as f:
expected = f.readlines()
- self.assertEqual(expected, actual)
+ self.assertEqual(self._remove_size_lines(expected),
+ self._remove_size_lines(actual))
def _test_main_out(self):
out_file = os.path.join(self.test_dir, 'main.out')
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath-multi.so.txt
index 59db4c5..e2a2e3a 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6220
+RO_SEG_FILE_SIZE 880
+RO_SEG_MEM_SIZE 880
+RW_SEG_FILE_SIZE 280
+RW_SEG_MEM_SIZE 280
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath.so.txt
index 1c19446..91e2664 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6220
+RO_SEG_FILE_SIZE 864
+RO_SEG_MEM_SIZE 864
+RW_SEG_FILE_SIZE 280
+RW_SEG_MEM_SIZE 280
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath-multi.so.txt
index 0d42f82..17b8905 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6220
+RO_SEG_FILE_SIZE 880
+RO_SEG_MEM_SIZE 880
+RW_SEG_FILE_SIZE 280
+RW_SEG_MEM_SIZE 280
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath.so.txt
index ab70935..9063ffe 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6220
+RO_SEG_FILE_SIZE 864
+RO_SEG_MEM_SIZE 864
+RW_SEG_FILE_SIZE 280
+RW_SEG_MEM_SIZE 280
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest.so.txt
index 54f89ae..474a117 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6220
+RO_SEG_FILE_SIZE 844
+RO_SEG_MEM_SIZE 844
+RW_SEG_FILE_SIZE 272
+RW_SEG_MEM_SIZE 272
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
EXP_SYMBOL _edata
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/main.out.txt
index 7f5dbac..c00f692 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_ARM
+FILE_SIZE 6776
+RO_SEG_FILE_SIZE 1646
+RO_SEG_MEM_SIZE 1646
+RW_SEG_FILE_SIZE 344
+RW_SEG_MEM_SIZE 348
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath-multi.so.txt
index 2cece74..ba3832f 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 7296
+RO_SEG_FILE_SIZE 1248
+RO_SEG_MEM_SIZE 1248
+RW_SEG_FILE_SIZE 520
+RW_SEG_MEM_SIZE 520
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath.so.txt
index 028080e..07265eb 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 7296
+RO_SEG_FILE_SIZE 1248
+RO_SEG_MEM_SIZE 1248
+RW_SEG_FILE_SIZE 520
+RW_SEG_MEM_SIZE 520
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath-multi.so.txt
index 2d97f6d..090280b 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 7296
+RO_SEG_FILE_SIZE 1248
+RO_SEG_MEM_SIZE 1248
+RW_SEG_FILE_SIZE 520
+RW_SEG_MEM_SIZE 520
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath.so.txt
index eb88f22..ba19600 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 7296
+RO_SEG_FILE_SIZE 1248
+RO_SEG_MEM_SIZE 1248
+RW_SEG_FILE_SIZE 520
+RW_SEG_MEM_SIZE 520
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest.so.txt
index 4b2bac6..080aa09 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 7296
+RO_SEG_FILE_SIZE 1232
+RO_SEG_MEM_SIZE 1232
+RW_SEG_FILE_SIZE 504
+RW_SEG_MEM_SIZE 504
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/main.out.txt
index c1750e3..7cd39f8 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/arm64/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_AARCH64
+FILE_SIZE 8256
+RO_SEG_FILE_SIZE 2410
+RO_SEG_MEM_SIZE 2410
+RW_SEG_FILE_SIZE 664
+RW_SEG_MEM_SIZE 664
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath-multi.so.txt
index e560cc9..3a5ab9a 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 6660
+RO_SEG_FILE_SIZE 1180
+RO_SEG_MEM_SIZE 1180
+RW_SEG_FILE_SIZE 308
+RW_SEG_MEM_SIZE 308
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath.so.txt
index 45a48aa..7e16d5f 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 6660
+RO_SEG_FILE_SIZE 1164
+RO_SEG_MEM_SIZE 1164
+RW_SEG_FILE_SIZE 308
+RW_SEG_MEM_SIZE 308
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath-multi.so.txt
index 51b821b..a3afbde 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 6660
+RO_SEG_FILE_SIZE 1180
+RO_SEG_MEM_SIZE 1180
+RW_SEG_FILE_SIZE 308
+RW_SEG_MEM_SIZE 308
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath.so.txt
index 0400e61..9bfb835 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 6660
+RO_SEG_FILE_SIZE 1164
+RO_SEG_MEM_SIZE 1164
+RW_SEG_FILE_SIZE 308
+RW_SEG_MEM_SIZE 308
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest.so.txt
index ff112d5..3266488 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 6660
+RO_SEG_FILE_SIZE 1164
+RO_SEG_MEM_SIZE 1164
+RW_SEG_FILE_SIZE 300
+RW_SEG_MEM_SIZE 300
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/main.out.txt
index 5a81d93..716a8eb 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7936
+RO_SEG_FILE_SIZE 2384
+RO_SEG_MEM_SIZE 2384
+RW_SEG_FILE_SIZE 396
+RW_SEG_MEM_SIZE 416
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath-multi.so.txt
index cb3216e..b29f77f 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7640
+RO_SEG_FILE_SIZE 2092
+RO_SEG_MEM_SIZE 2092
+RW_SEG_FILE_SIZE 104
+RW_SEG_MEM_SIZE 104
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath.so.txt
index 6cc3272..c4d1cc6 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7640
+RO_SEG_FILE_SIZE 2092
+RO_SEG_MEM_SIZE 2092
+RW_SEG_FILE_SIZE 104
+RW_SEG_MEM_SIZE 104
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath-multi.so.txt
index 86578ac..60342cc 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7640
+RO_SEG_FILE_SIZE 2092
+RO_SEG_MEM_SIZE 2092
+RW_SEG_FILE_SIZE 104
+RW_SEG_MEM_SIZE 104
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath.so.txt
index be2b32b..b115068 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7640
+RO_SEG_FILE_SIZE 2092
+RO_SEG_MEM_SIZE 2092
+RW_SEG_FILE_SIZE 104
+RW_SEG_MEM_SIZE 104
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest.so.txt
index fe0f6bb..4f72c60 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 7640
+RO_SEG_FILE_SIZE 2060
+RO_SEG_MEM_SIZE 2060
+RW_SEG_FILE_SIZE 104
+RW_SEG_MEM_SIZE 104
DT_NEEDED libc.so
EXP_SYMBOL __bss_end__
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/main.out.txt
index 441a815..47cc08b 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/mips64/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_MIPS
+FILE_SIZE 9568
+RO_SEG_FILE_SIZE 3448
+RO_SEG_MEM_SIZE 3448
+RW_SEG_FILE_SIZE 216
+RW_SEG_MEM_SIZE 240
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath-multi.so.txt
index 73b0e89..540a228 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6212
+RO_SEG_FILE_SIZE 1364
+RO_SEG_MEM_SIZE 1364
+RW_SEG_FILE_SIZE 284
+RW_SEG_MEM_SIZE 284
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath.so.txt
index f974860..06b6bb6 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6212
+RO_SEG_FILE_SIZE 1348
+RO_SEG_MEM_SIZE 1348
+RW_SEG_FILE_SIZE 284
+RW_SEG_MEM_SIZE 284
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath-multi.so.txt
index 301c13d..c285100 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6212
+RO_SEG_FILE_SIZE 1364
+RO_SEG_MEM_SIZE 1364
+RW_SEG_FILE_SIZE 284
+RW_SEG_MEM_SIZE 284
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath.so.txt
index 944a98c..560e823 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6212
+RO_SEG_FILE_SIZE 1348
+RO_SEG_MEM_SIZE 1348
+RW_SEG_FILE_SIZE 284
+RW_SEG_MEM_SIZE 284
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest.so.txt
index 992f48b..7df95ed 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6212
+RO_SEG_FILE_SIZE 1316
+RO_SEG_MEM_SIZE 1316
+RW_SEG_FILE_SIZE 276
+RW_SEG_MEM_SIZE 276
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
EXP_SYMBOL _edata
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/main.out.txt
index ec0edb9..4801fdd 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 32
EI_DATA Little-Endian
E_MACHINE EM_386
+FILE_SIZE 6680
+RO_SEG_FILE_SIZE 1992
+RO_SEG_MEM_SIZE 1992
+RW_SEG_FILE_SIZE 288
+RW_SEG_MEM_SIZE 292
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath-multi.so.txt
index efa204f..da530ff 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 6888
+RO_SEG_FILE_SIZE 1456
+RO_SEG_MEM_SIZE 1456
+RW_SEG_FILE_SIZE 560
+RW_SEG_MEM_SIZE 560
DT_RPATH /system/lib
DT_RPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath.so.txt
index 5fc5b01..34d9865 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-rpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 6888
+RO_SEG_FILE_SIZE 1440
+RO_SEG_MEM_SIZE 1440
+RW_SEG_FILE_SIZE 560
+RW_SEG_MEM_SIZE 560
DT_RPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath-multi.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath-multi.so.txt
index bad50ed..8f12078 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath-multi.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath-multi.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 6888
+RO_SEG_FILE_SIZE 1456
+RO_SEG_MEM_SIZE 1456
+RW_SEG_FILE_SIZE 560
+RW_SEG_MEM_SIZE 560
DT_RUNPATH /system/lib
DT_RUNPATH /vendor/lib
DT_NEEDED libc.so
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath.so.txt
index adf06b4..47bc2ff 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest-runpath.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 6888
+RO_SEG_FILE_SIZE 1440
+RO_SEG_MEM_SIZE 1440
+RW_SEG_FILE_SIZE 560
+RW_SEG_MEM_SIZE 560
DT_RUNPATH $ORIGIN/../lib
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest.so.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest.so.txt
index c9f14fe..e7a2aaa 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest.so.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/libtest.so.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 6888
+RO_SEG_FILE_SIZE 1424
+RO_SEG_MEM_SIZE 1424
+RW_SEG_FILE_SIZE 544
+RW_SEG_MEM_SIZE 544
DT_NEEDED libc.so
EXP_SYMBOL __bss_start
EXP_SYMBOL _edata
diff --git a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/main.out.txt b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/main.out.txt
index 3a63951..a1c9466 100644
--- a/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/main.out.txt
+++ b/vndk/tools/definition-tool/tests/testdata/test_elfdump/expected/x86_64/main.out.txt
@@ -1,6 +1,11 @@
EI_CLASS 64
EI_DATA Little-Endian
E_MACHINE EM_X86_64
+FILE_SIZE 7584
+RO_SEG_FILE_SIZE 2248
+RO_SEG_MEM_SIZE 2248
+RW_SEG_FILE_SIZE 664
+RW_SEG_MEM_SIZE 672
DT_NEEDED libdl.so
DT_NEEDED libc.so
DT_NEEDED libstdc++.so
diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py
index 73cb7f2..6887c75 100755
--- a/vndk/tools/definition-tool/vndk_definition_tool.py
+++ b/vndk/tools/definition-tool/vndk_definition_tool.py
@@ -121,6 +121,11 @@
'sh_addralign sh_entsize')
+Elf_Phdr = collections.namedtuple(
+ 'Elf_Phdr',
+ 'p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align')
+
+
Elf_Dyn = collections.namedtuple('Elf_Dyn', 'd_tag d_val')
@@ -173,6 +178,12 @@
ELFDATA2LSB = 1
ELFDATA2MSB = 2
+ PT_LOAD = 1
+
+ PF_X = 1
+ PF_W = 2
+ PF_R = 4
+
DT_NEEDED = 1
DT_RPATH = 15
DT_RUNPATH = 29
@@ -227,12 +238,16 @@
__slots__ = ('ei_class', 'ei_data', 'e_machine', 'dt_rpath', 'dt_runpath',
- 'dt_needed', 'exported_symbols', 'imported_symbols',)
+ 'dt_needed', 'exported_symbols', 'imported_symbols',
+ 'file_size', 'ro_seg_file_size', 'ro_seg_mem_size',
+ 'rw_seg_file_size', 'rw_seg_mem_size',)
def __init__(self, ei_class=ELFCLASSNONE, ei_data=ELFDATANONE, e_machine=0,
dt_rpath=None, dt_runpath=None, dt_needed=None,
- exported_symbols=None, imported_symbols=None):
+ exported_symbols=None, imported_symbols=None,
+ file_size=0, ro_seg_file_size=0, ro_seg_mem_size=0,
+ rw_seg_file_size=0, rw_seg_mem_size=0):
self.ei_class = ei_class
self.ei_data = ei_data
self.e_machine = e_machine
@@ -243,6 +258,11 @@
exported_symbols if exported_symbols is not None else set()
self.imported_symbols = \
imported_symbols if imported_symbols is not None else set()
+ self.file_size = file_size
+ self.ro_seg_file_size = ro_seg_file_size
+ self.ro_seg_mem_size = ro_seg_mem_size
+ self.rw_seg_file_size = rw_seg_file_size
+ self.rw_seg_mem_size = rw_seg_mem_size
def __repr__(self):
args = (a + '=' + repr(getattr(self, a)) for a in self.__slots__)
@@ -286,6 +306,11 @@
print('EI_CLASS\t' + self.elf_class_name, file=file)
print('EI_DATA\t\t' + self.elf_data_name, file=file)
print('E_MACHINE\t' + self.elf_machine_name, file=file)
+ print('FILE_SIZE\t' + str(self.file_size), file=file)
+ print('RO_SEG_FILE_SIZE\t' + str(self.ro_seg_file_size), file=file)
+ print('RO_SEG_MEM_SIZE\t' + str(self.ro_seg_mem_size), file=file)
+ print('RW_SEG_FILE_SIZE\t' + str(self.rw_seg_file_size), file=file)
+ print('RW_SEG_MEM_SIZE\t' + str(self.rw_seg_mem_size), file=file)
for dt_rpath in self.dt_rpath:
print('DT_RPATH\t' + dt_rpath, file=file)
for dt_runpath in self.dt_runpath:
@@ -334,17 +359,21 @@
if self.ei_data not in (ELF.ELFDATA2LSB, ELF.ELFDATA2MSB):
raise ELFError('unknown endianness')
+ self.file_size = buf.size()
+
# ELF structure definitions.
endian_fmt = '<' if self.ei_data == ELF.ELFDATA2LSB else '>'
if self.is_32bit:
elf_hdr_fmt = endian_fmt + '4x4B8xHHLLLLLHHHHHH'
elf_shdr_fmt = endian_fmt + 'LLLLLLLLLL'
+ elf_phdr_fmt = endian_fmt + 'LLLLLLLL'
elf_dyn_fmt = endian_fmt + 'lL'
elf_sym_fmt = endian_fmt + 'LLLBBH'
else:
elf_hdr_fmt = endian_fmt + '4x4B8xHHLQQQLHHHHHH'
elf_shdr_fmt = endian_fmt + 'LLQQQQLLQQ'
+ elf_phdr_fmt = endian_fmt + 'LLQQQQQQ'
elf_dyn_fmt = endian_fmt + 'QQ'
elf_sym_fmt = endian_fmt + 'LBBHQQ'
@@ -361,6 +390,19 @@
return parse_struct(Elf_Shdr, elf_shdr_fmt, offset,
'bad section header')
+ if self.is_32bit:
+ def parse_elf_phdr(offset):
+ return parse_struct(Elf_Phdr, elf_phdr_fmt, offset,
+ 'bad program header')
+ else:
+ def parse_elf_phdr(offset):
+ try:
+ p = struct.unpack_from(elf_phdr_fmt, buf, offset)
+ return Elf_Phdr(p[0], p[2], p[3], p[4], p[5], p[6], p[1],
+ p[7])
+ except struct.error:
+ raise ELFError('bad program header')
+
def parse_elf_dyn(offset):
return parse_struct(Elf_Dyn, elf_dyn_fmt, offset,
'bad .dynamic entry')
@@ -383,6 +425,33 @@
header = parse_elf_hdr(0)
self.e_machine = header.e_machine
+ # Parse ELF program header and calculate segment size.
+ if header.e_phentsize == 0:
+ raise ELFError('no program header')
+
+ ro_seg_file_size = 0
+ ro_seg_mem_size = 0
+ rw_seg_file_size = 0
+ rw_seg_mem_size = 0
+
+ assert struct.calcsize(elf_phdr_fmt) == header.e_phentsize
+ seg_end = header.e_phoff + header.e_phnum * header.e_phentsize
+ for phdr_off in range(header.e_phoff, seg_end, header.e_phentsize):
+ phdr = parse_elf_phdr(phdr_off)
+ if phdr.p_type != ELF.PT_LOAD:
+ continue
+ if phdr.p_flags & ELF.PF_W:
+ rw_seg_file_size += phdr.p_filesz
+ rw_seg_mem_size += phdr.p_memsz
+ else:
+ ro_seg_file_size += phdr.p_filesz
+ ro_seg_mem_size += phdr.p_memsz
+
+ self.ro_seg_file_size = ro_seg_file_size
+ self.ro_seg_mem_size = ro_seg_mem_size
+ self.rw_seg_file_size = rw_seg_file_size
+ self.rw_seg_mem_size = rw_seg_mem_size
+
# Check section header size.
if header.e_shentsize == 0:
raise ELFError('no section header')
@@ -481,6 +550,16 @@
self.ei_data = ELF.get_ei_data_from_name(value)
elif key == 'E_MACHINE':
self.e_machine = ELF.get_e_machine_from_name(value)
+ elif key == 'FILE_SIZE':
+ self.file_size = int(value)
+ elif key == 'RO_SEG_FILE_SIZE':
+ self.ro_seg_file_size = int(value)
+ elif key == 'RO_SEG_MEM_SIZE':
+ self.ro_seg_mem_size = int(value)
+ elif key == 'RW_SEG_FILE_SIZE':
+ self.rw_seg_file_size = int(value)
+ elif key == 'RW_SEG_MEM_SIZE':
+ self.rw_seg_mem_size = int(value)
elif key == 'DT_RPATH':
self.dt_rpath.append(intern(value))
elif key == 'DT_RUNPATH':
@@ -2056,6 +2135,10 @@
'--output-format', default='tag',
help='output format for vndk classification')
+ parser.add_argument(
+ '--file-size-output',
+ help='output file for calculated file sizes')
+
def _warn_incorrect_partition_lib_set(self, lib_set, partition, error_msg):
for lib in lib_set.values():
if not lib.num_users:
@@ -2140,6 +2223,69 @@
file.write(template)
+ def _print_file_size_output(self, graph, vndk_lib, file=sys.stderr):
+ def collect_tags(lib):
+ tags = []
+ for field_name in _VNDK_RESULT_FIELD_NAMES:
+ if lib in getattr(vndk_lib, field_name):
+ tags.append(field_name)
+ return ' '.join(tags)
+
+ writer = csv.writer(file, lineterminator='\n')
+ writer.writerow(('Path', 'Tag', 'File size', 'RO segment file size',
+ 'RO segment mem size', 'RW segment file size',
+ 'RW segment mem size'))
+
+ # Print the file size of all ELF files.
+ for lib in sorted(graph.all_libs()):
+ writer.writerow((lib.path, collect_tags(lib), lib.elf.file_size,
+ lib.elf.ro_seg_file_size, lib.elf.ro_seg_mem_size,
+ lib.elf.rw_seg_file_size, lib.elf.rw_seg_mem_size))
+
+ # Calculate the summation of each sets.
+ def calc_total_size(lib_set):
+ total_file_size = 0
+ total_ro_seg_file_size = 0
+ total_ro_seg_mem_size = 0
+ total_rw_seg_file_size = 0
+ total_rw_seg_mem_size = 0
+
+ for lib in lib_set:
+ total_file_size += lib.elf.file_size
+ total_ro_seg_file_size += lib.elf.ro_seg_file_size
+ total_ro_seg_mem_size += lib.elf.ro_seg_mem_size
+ total_rw_seg_file_size += lib.elf.rw_seg_file_size
+ total_rw_seg_mem_size += lib.elf.rw_seg_mem_size
+
+ return [total_file_size, total_ro_seg_file_size,
+ total_ro_seg_mem_size, total_rw_seg_file_size,
+ total_rw_seg_mem_size]
+
+ SEPARATOR = ('----------', None, None, None, None, None, None)
+
+ writer.writerow(SEPARATOR)
+ for tag in _VNDK_RESULT_FIELD_NAMES:
+ lib_set = getattr(vndk_lib, tag)
+ lib_set = [lib for lib in lib_set if lib.elf.is_32bit]
+ total = calc_total_size(lib_set)
+ writer.writerow(['Subtotal ' + tag + ' (32-bit)', None] + total)
+
+ writer.writerow(SEPARATOR)
+ for tag in _VNDK_RESULT_FIELD_NAMES:
+ lib_set = getattr(vndk_lib, tag)
+ lib_set = [lib for lib in lib_set if not lib.elf.is_32bit]
+ total = calc_total_size(lib_set)
+ writer.writerow(['Subtotal ' + tag + ' (64-bit)', None] + total)
+
+ writer.writerow(SEPARATOR)
+ for tag in _VNDK_RESULT_FIELD_NAMES:
+ total = calc_total_size(getattr(vndk_lib, tag))
+ writer.writerow(['Subtotal ' + tag + ' (both)', None] + total)
+
+ # Calculate the summation of all ELF files.
+ writer.writerow(SEPARATOR)
+ writer.writerow(['Total', None] + calc_total_size(graph.all_libs()))
+
def main(self, args):
generic_refs, graph, tagged_paths = self.create_from_args(args)
@@ -2157,6 +2303,10 @@
else:
self._print_tags(vndk_lib, args.full)
+ # Calculate and print file sizes.
+ if args.file_size_output:
+ with open(args.file_size_output, 'w') as fp:
+ self._print_file_size_output(graph, vndk_lib, file=fp)
return 0
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/preprocess.py b/vndk/tools/source-deps-reviewer/sourcedr/preprocess.py
index fc19d97..9176fec 100755
--- a/vndk/tools/source-deps-reviewer/sourcedr/preprocess.py
+++ b/vndk/tools/source-deps-reviewer/sourcedr/preprocess.py
@@ -206,7 +206,6 @@
patt = re.compile(b'([^:]+):(\\d+):(.*)$')
suspect = collections.defaultdict(list)
for line in raw_grep.split(b'\n'):
-
match = patt.match(line)
if not match:
continue
@@ -265,21 +264,22 @@
for pattern, is_regex in zip(patterns, is_regexs):
if not is_regex:
pattern = re.escape(pattern)
- try:
- raw_grep = subprocess.check_output(
- ['csearch', '-n', pattern],
- cwd=os.path.expanduser(self.android_root),
- env=self.env)
- except subprocess.CalledProcessError as e:
- if e.output == b'':
- print('nothing found')
- return
+ raw_grep = self.raw_grep(pattern)
+ if raw_grep == b'':
+ continue
processed += self.process_grep(raw_grep, pattern, is_regex)
self.to_json(processed)
def add_pattern(self, pattern, is_regex):
if not is_regex:
pattern = re.escape(pattern)
+ raw_grep = self.raw_grep(pattern)
+ if raw_grep == b'':
+ return
+ processed = self.process_grep(raw_grep, pattern, is_regex)
+ self.add_to_json(processed)
+
+ def raw_grep(self, pattern):
try:
raw_grep = subprocess.check_output(
['csearch', '-n', pattern],
@@ -288,9 +288,13 @@
except subprocess.CalledProcessError as e:
if e.output == b'':
print('nothing found')
- return
- processed = self.process_grep(raw_grep, pattern, is_regex)
- self.add_to_json(processed)
+ return b''
+ return raw_grep
+
+ def raw_search(self, pattern, is_regex):
+ if not is_regex:
+ pattern = re.escape(pattern)
+ return self.raw_grep(pattern)
def to_json(self, processed):
data = {}
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/server.py b/vndk/tools/source-deps-reviewer/sourcedr/server.py
index 6cada2d..be4e323 100755
--- a/vndk/tools/source-deps-reviewer/sourcedr/server.py
+++ b/vndk/tools/source-deps-reviewer/sourcedr/server.py
@@ -6,9 +6,12 @@
from flask import Flask, jsonify, render_template, request
import argparse
import bisect
+import collections
+from functools import cmp_to_key
import hashlib
import json
import os
+import re
import subprocess
import sys
import webbrowser
@@ -95,6 +98,48 @@
save_new_pattern(patt, is_regex)
return jsonify(result='done')
+
+# This function does a temporary grep to the directory
+# Not adding the result to database
+@app.route('/temporary_search')
+def _temporary_search():
+ path = request.args.get('path')
+ patt = request.args.get('pattern')
+ is_regex = request.args.get('is_regex')
+ result = engine.raw_search(patt, is_regex).decode('utf-8')
+ dic = collections.defaultdict(list)
+ patt = re.compile('([^:]+):(\\d+):(.*)$')
+ for line in result.split('\n'):
+ match = patt.match(line)
+ if not match:
+ continue
+
+ file_path = match.group(1)
+ line_no = match.group(2)
+ code = match.group(3)
+ dic[file_path].append((line_no, code))
+
+ def compare(item1, item2):
+ key1, value1 = item1
+ key2, value2 = item2
+ cnt1 = os.path.commonprefix([path, key1]).count('/')
+ cnt2 = os.path.commonprefix([path, key2]).count('/')
+ e1 = os.path.relpath(key1, path).count('/')
+ e2 = os.path.relpath(key2, path).count('/')
+ # prefer smaller edit distance
+ if e1 < e2: return -1
+ if e2 < e1: return 1
+ # prefer deeper common ancestor
+ if cnt1 > cnt2: return -1
+ if cnt2 > cnt1: return 1
+ # lexicographical order
+ if key1 < key2: return -1
+ if key2 < key1: return 1
+ return 0
+
+ result = sorted(dic.items(), key=cmp_to_key(compare))
+ return jsonify(result=json.dumps(result))
+
@app.route('/')
def render():
return render_template('index.html')
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/static/css/main.css b/vndk/tools/source-deps-reviewer/sourcedr/static/css/main.css
index 933f73a..11bb7bc 100644
--- a/vndk/tools/source-deps-reviewer/sourcedr/static/css/main.css
+++ b/vndk/tools/source-deps-reviewer/sourcedr/static/css/main.css
@@ -1,13 +1,26 @@
h3, h4 {
- display: inline-block;
+ display: inline-block;
}
pre {
- white-space: pre-wrap; /* Since CSS 2.1 */
- white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
- background-color: #ffffff;
- margin: 0;
+ white-space: pre-wrap; /* Since CSS 2.1 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+ background-color: #ffffff;
+ margin: 0;
+}
+
+@media (min-width: 768px) {
+ .modal-xl {
+ width: 90%;
+ max-width:1200px;
+ }
+}
+
+.affix {
+ top:50px;
+ right:0;
+ position:fixed;
}
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/static/js/main.js b/vndk/tools/source-deps-reviewer/sourcedr/static/js/main.js
index e11d26c..db62041 100644
--- a/vndk/tools/source-deps-reviewer/sourcedr/static/js/main.js
+++ b/vndk/tools/source-deps-reviewer/sourcedr/static/js/main.js
@@ -37,6 +37,33 @@
return pretag;
}
+ function grepResultHtml(items) {
+ let ret = document.createElement('p');
+ for (let i = 0; i < items.length; i++) {
+ let path = document.createElement('span');
+ path.style.color = 'purple';
+ path.style.fontSize = '20px';
+ path.innerHTML = items[i][0];
+ ret.appendChild(path);
+ ret.appendChild(document.createElement('br'));
+ for (let j = 0; j < items[0][1].length; j++) {
+ let line_no = items[i][1][j][0];
+ let content = items[i][1][j][1];
+ let line_html = document.createElement('font');
+ line_html.style.color = 'green';
+ line_html.style.fontSize = '18px';
+ line_html.innerHTML = line_no + ':';
+ ret.appendChild(line_html);
+ let content_html = document.createElement('span');
+ content_html.style.fontSize = '18px';
+ content_html.appendChild(document.createTextNode(content));
+ ret.appendChild(content_html);
+ ret.appendChild(document.createElement('br'));
+ }
+ }
+ return ret;
+ }
+
function enterTask() {
let text = $('#enter_deps').val();
$('#deps_list').append(taskHtml(text, counter));
@@ -104,7 +131,6 @@
for (let i = 0; i < len; i++) {
$('#pattern_list').append('<li>' + pattern_lst[i] + '</li>');
}
-
$('#path_prefix').text(data.path_prefix);
});
}
@@ -199,6 +225,7 @@
setGotoPatternLine(line_no);
$('#selected_text').val('');
$('#code_file_path').val('');
+ $('#enter_deps').val('');
$('html,body').scrollTop(0);
return false;
}
@@ -227,8 +254,30 @@
pattern: values['pattern'],
is_regex: $('#is_regex').is(':checked') ? 1 : 0
});
+ return true;
+ });
+
+ $('#temporary_search').submit(function() {
+ const $inputs = $('#temporary_search :input');
+ let values = {};
+ $inputs.each(function () {
+ values[this.name] = $(this).val();
+ });
+ $('#modal_title').text(values['pattern']);
+ $.getJSON('/temporary_search', {
+ path: $('#file_path').text(),
+ pattern: values['pattern'],
+ is_regex: $('#is_regex2').is(':checked') ? 1 : 0
+ }, function (data) {
+ $('#modal_body').append(grepResultHtml(JSON.parse(data.result)));
+ $('#myModal').modal('show');
+ });
return false;
});
+ // clear previous html code in modal on hide
+ $('#myModal').on('hidden.bs.modal', function () {
+ $('#modal_body').empty();
+ })
$('#add_deps').submit(enterTask);
$('#add_code').submit(enterCode);
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/static/prism/js/prism.js b/vndk/tools/source-deps-reviewer/sourcedr/static/prism/js/prism.js
index 758b01b..743a225 100644
--- a/vndk/tools/source-deps-reviewer/sourcedr/static/prism/js/prism.js
+++ b/vndk/tools/source-deps-reviewer/sourcedr/static/prism/js/prism.js
@@ -635,9 +635,17 @@
}
}());
+function getOffsetById(id) {
+ var element = document.getElementById(id);
+ var bodyRect = document.body.getBoundingClientRect();
+ var elemRect = element.getBoundingClientRect();
+ var elementOffset = elemRect.top - bodyRect.top;
+ return elementOffset;
+}
+
function highlightLines(pre, lines, classes) {
- var ranges = lines.replace(/\s+/g, '').split(','),
- offset = +pre.getAttribute('data-line-offset') || 0;
+ var ranges = lines.replace(/\s+/g, '').split(',');
+ var offset = getOffsetById('browsing_file');
var parseMethod = isLineHeightRounded() ? parseInt : parseFloat;
var lineHeight = parseMethod(getComputedStyle(pre).lineHeight);
@@ -663,7 +671,7 @@
}
}
- line.style.top = (start - offset - 1) * lineHeight + 'px';
+ line.style.top = (getOffsetById('line_no' + start) - offset) + 'px';
//allow this to play nicely with the line-numbers plugin
if(hasClass(pre, 'line-numbers')) {
@@ -734,33 +742,6 @@
}
});
-Prism.hooks.add('complete', function(env) {
- var pre = env.element.parentNode;
- var lines = pre && pre.getAttribute('data-line');
-
- if (!pre || !lines || !/pre/i.test(pre.nodeName)) {
- return;
- }
-
- clearTimeout(fakeTimer);
-
- highlightLines(pre, lines);
-
- fakeTimer = setTimeout(applyHash, 1);
-});
-
-if(window.addEventListener) {
- window.addEventListener('hashchange', applyHash);
-}
-
-})();
-
-(function() {
-
-if (typeof self === 'undefined' || !self.Prism || !self.document) {
- return;
-}
-
Prism.hooks.add('complete', function (env) {
if (!env.code) {
return;
@@ -795,8 +776,10 @@
var linesNum = match ? match.length + 1 : 1;
var lineNumbersWrapper;
- var lines = new Array(linesNum + 1);
- lines = lines.join('<span></span>');
+ var lines = '';
+ for (let i = 1; i < linesNum + 1; i++) {
+ lines += '<span id="line_no' + i + '"></span>';
+ }
lineNumbersWrapper = document.createElement('span');
lineNumbersWrapper.setAttribute('aria-hidden', 'true');
@@ -811,4 +794,31 @@
});
+Prism.hooks.add('complete', function(env) {
+ var pre = env.element.parentNode;
+ var lines = pre && pre.getAttribute('data-line');
+
+ if (!pre || !lines || !/pre/i.test(pre.nodeName)) {
+ return;
+ }
+
+ clearTimeout(fakeTimer);
+
+ highlightLines(pre, lines);
+
+ fakeTimer = setTimeout(applyHash, 1);
+});
+
+if(window.addEventListener) {
+ window.addEventListener('hashchange', applyHash);
+}
+
+})();
+
+(function() {
+
+if (typeof self === 'undefined' || !self.Prism || !self.document) {
+ return;
+}
+
}());
diff --git a/vndk/tools/source-deps-reviewer/sourcedr/templates/index.html b/vndk/tools/source-deps-reviewer/sourcedr/templates/index.html
index e46b3bf..9cf75ec 100644
--- a/vndk/tools/source-deps-reviewer/sourcedr/templates/index.html
+++ b/vndk/tools/source-deps-reviewer/sourcedr/templates/index.html
@@ -32,8 +32,17 @@
</div>
<br>
- <div class="col-sm-4">
+ <div class="col-sm-4" data-spy="affix">
+
<div class="well">
+ <h3>Temporary search</h3>
+ <form id="temporary_search" class="input-group" style="padding-left:20px;">
+ <span class="input-group-addon">is regex</span>
+ <span class="input-group-addon">
+ <input type="checkbox" name="is_regex2" id="is_regex2">
+ </span>
+ <input type="text" name="pattern" class="form-control">
+ </form>
<h3>Add patterns to grep</h3>
<form id="add_pattern" class="input-group" style="padding-left:20px;">
<span class="input-group-addon">is regex</span>
@@ -43,12 +52,12 @@
<input type="text" name="pattern" class="form-control">
</form>
<ul id="pattern_list"></ul>
- <h3>File path:</h3>
+ </div>
+ <div class="well">
+ <h3>File labeling:</h3>
<pre style="padding-left:20px;"><h4 id="file_path"></h4></pre>
<h3>Pattern line number:</h3>
<h3 id="line_no"></h3><br>
- </div>
- <div class="well">
<h3>Library Dependencies</h3>
<form id="add_deps" class="input-group">
<input type="text" class="form-control" id="enter_deps" placeholder="Fill in * if undetermined"/>
@@ -57,15 +66,14 @@
</span>
</form>
<ul id="deps_list"></ul>
-
<h3>Code Dependencies</h3>
<form id="add_code">
<input class="btn btn-secondary" type="button" id="get_selection" value="Get selection"/>
<input class="btn btn-secondary" type="submit" id="add_code" value="Add"/><br>
<input type="text" id="code_file_path" style="margin: 0px; width: 100%;"/>
<textarea id="selected_text" name="selectedtext" rows="5" style="margin: 0px; width: 100%; height: 106px;"></textarea>
- <ul id="code_list"></ul>
</form>
+ <ul id="code_list"></ul>
<form id="save_all">
<input class="btn btn-secondary" type="submit" value="Save All"/>
</form>
@@ -74,11 +82,27 @@
</div>
</div>
+<!-- Modal -->
+<div class="modal fade" id="myModal" role="dialog">
+ <div class="modal-dialog modal-xl">
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">×</button>
+ <h4 id="modal_title" class="modal-title"></h4>
+ </div>
+ <div id="modal_body" class="modal-body">
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+</div>
<script type="text/javascript" src="static/js/main.js"></script>
<!-- for code prettyify -->
<script src="static/prism/js/prism.js"></script>
-<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</body>
</html>