Commit Graph

17395 Commits

Author SHA1 Message Date
Automerger Merge Worker
42ff47b5df Merge "Support apps attribute in apex_defaults" am: 1d1a920794 am: dc1c78fcd1
Change-Id: I2ae2f868effd2997b2eea6cf8b301e2e04e446d9
2019-12-17 06:03:19 +00:00
Jooyung Han
dc1c78fcd1 Merge "Support apps attribute in apex_defaults"
am: 1d1a920794

Change-Id: Ibfa92edacbb7c041d6d1ac01f5a0baf64b9562a3
2019-12-16 21:48:50 -08:00
Treehugger Robot
1d1a920794 Merge "Support apps attribute in apex_defaults" 2019-12-17 05:44:42 +00:00
Automerger Merge Worker
991e40ba6f Merge "Avoid duplicated classes for boot dex jars" am: 97e09d0dee am: a40bb59741
Change-Id: I0ec332afa9e4b2ff24ba7f426b2c8f8711fc0316
2019-12-17 05:38:20 +00:00
Jiyong Park
a40bb59741 Merge "Avoid duplicated classes for boot dex jars"
am: 97e09d0dee

Change-Id: Iaf95a4cd63f57df1b5e6fab64c382308f3682e0d
2019-12-16 21:19:43 -08:00
Treehugger Robot
97e09d0dee Merge "Avoid duplicated classes for boot dex jars" 2019-12-17 05:14:25 +00:00
Automerger Merge Worker
50a9cadcf4 Merge "Add $ORIGIN to fuzzer-coverage sanitized .so's." am: a1682631eb am: 630f2d4caf
Change-Id: Icf7e06ae9ef99b6a05803931c83d425cb4ab44b0
2019-12-16 21:33:47 +00:00
Mitch Phillips
630f2d4caf Merge "Add $ORIGIN to fuzzer-coverage sanitized .so's."
am: a1682631eb

Change-Id: I5748c74b623488b82c94c82ac0a14839f188dc26
2019-12-16 13:23:53 -08:00
Automerger Merge Worker
a923639223 Merge changes from topic "separate_code" am: 894cdee30a am: 7346c709e2
Change-Id: Iff366bacfb9db627f1a73ad1fa7b7a610f0b1a1d
2019-12-16 21:22:58 +00:00
Automerger Merge Worker
1ae7cbd085 Revert "Revert "soong: upgrade Android platform to clang-r370808"" am: eb20744361 am: c2e2dce120
Change-Id: Ieff5a930b0b8ff66cc5b714f497daae0b0255b70
2019-12-16 21:22:55 +00:00
Automerger Merge Worker
7ff356d5a0 Merge "Use empty string for core image variant" am: bd0624304e am: 2387d4f65e
Change-Id: Id3bb879347c3e3152f1e2cabf2aeb759d1b1c187
2019-12-16 21:22:06 +00:00
Nick Desaulniers
7346c709e2 Merge changes from topic "separate_code"
am: 894cdee30a

Change-Id: I8e20f744c85a7439569fe5f0464c74e91d060c30
2019-12-16 13:20:22 -08:00
Nick Desaulniers
c2e2dce120 Revert "Revert "soong: upgrade Android platform to clang-r370808""
am: eb20744361

Change-Id: Ia0c47b43fcb53da68caf6496fb2a421c74581a02
2019-12-16 13:20:15 -08:00
Mitch Phillips
a1682631eb Merge "Add $ORIGIN to fuzzer-coverage sanitized .so's." 2019-12-16 21:17:03 +00:00
Nick Desaulniers
894cdee30a Merge changes from topic "separate_code"
* changes:
  soong: use -Wl,-z,separate-code w/ -Wl,--execute-only
  Revert "Revert "soong: upgrade Android platform to clang-r370808""
2019-12-16 21:13:28 +00:00
Colin Cross
2387d4f65e Merge "Use empty string for core image variant"
am: bd0624304e

Change-Id: I0ccff110f6661a47e303c1a84ae18d6adfcebaa9
2019-12-16 13:06:12 -08:00
Treehugger Robot
bd0624304e Merge "Use empty string for core image variant" 2019-12-16 20:54:32 +00:00
Nick Desaulniers
dcee1e5c54 soong: use -Wl,-z,separate-code w/ -Wl,--execute-only
The clang-r370808 upgrade contains a change to LLD allow PT_LOAD
segments to reside at non-multiples of the page size in the resulting
object file.  https://reviews.llvm.org/rL369344

While this helps reduce the alignment waste and resulting image size, it
has interesting implications for execute only memory (XOM): The runtime
loader will now load code or data from other segments into pages with
different protections than intended.

This would partially defeat execute only (XOM) text sections as the
segment could now overlap with previous and following sections. This
might allow for code or data from the preceding and following sections
(like .eh_frame, and .data.rel.ro) to be executable, and either ends of
.text to be readable.

When the runtime loader (linker[64]) `mmap`s segments from *.so files,
the file offset parameter (see `man 2 mmap`) MUST be a multiple of the
page size.  Since the updated LLD can now pack segments in a file (which
helps minimize resulting object file size) (previously, the segment
offsets were page aligned), this has interesting implications.

To appreciate the current bug, consider the following output from
`readelf` before this patch is applied, but after the toolchain upgrade:

```
$ readelf -lSW $OUT/symbols/apex/com.android.runtime/lib64/bionic/libc.so
...
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
...
  [13] .eh_frame         PROGBITS        000000000002e7c0 02e7c0 013374 00   A  0   0  8
  [14] .text             PROGBITS        0000000000042b40 041b40 09ecb4 00  AX  0   0 64
  [15] .plt              PROGBITS        00000000000e1800 0e0800 001f30 00  AX  0   0 16
  [16] .data.rel.ro      PROGBITS        00000000000e4740 0e2740 005208 00  WA  0   0 32
...
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000230 0x000230 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x041b34 0x041b34 R   0x1000
  LOAD           0x041b40 0x0000000000042b40 0x0000000000042b40 0x0a0bf0 0x0a0bf0   E 0x1000
  LOAD           0x0e2740 0x00000000000e4740 0x00000000000e4740 0x006720 0x006720 RW  0x1000
...
   01     .note.android.ident .note.gnu.build-id .dynsym .gnu.version .gnu.version_d .gnu.version_r .gnu.hash .dynstr .rela.dyn .rela.plt .rodata .eh_frame_hdr .eh_frame
   02     .text .plt
   03     .data.rel.ro .fini_array .init_array .dynamic .got .got.plt
...

The above output tells us:
1. .text will wind up in the third (02) segment.
2. The third segment will be (LOAD)'ed as (E)xecutable.
3. Because the file (Offset) of the first segment (0x41b40) is NOT a
   multiple of the page size, it cannot be passed as the `offset` to
   `mmap`. As such it will be rounded down to the first multiple of the
   page size, 0x41000.
4. The preceding section (.eh_frame) will be loaded in the preceding
   segment (01). It occupies file (Off)set range [(0x2e7c0):0x41b34].
   0x41b34 is not explicit in the output, instead you must use the
   formula:
     Off     + Size    == End
   ie.
     0x2e7c0 + 0x13374 == 0x41b34
   (This happens to match (FileSiz) of the second segment, which makes
   sense as .eh_frame is the final section in the second segment.)
5. mmap'ing file offset 0x41000 when loading the second segment will
   include 0x4c0 bytes (0x42000 - 0x41b40) from .text, now mapped as
   readable (oops). Suddenly code from .text is now readable (and thus
   scannable for gadgets for ROP chains).
6. mmap'ing file offset 0x41000 when loading the third segment will
   include 0xb34 bytes (0x41b34 - 0x41000) from .eh_frame, now mapped as
   executable (oops). Suddenly data from .eh_frame is now executable
   (and thus a potential gadget for ROP chains).
7. mmap'ing file offset 0xe2000 when loading the third segment will
   include 0x8CO bytes (0xe3000 - 0xe2740) from .data.rel.ro, now mapped
   as executable (oops). Suddenly data from .data.rel.ro is now
   executable (and thus a potential gadget for ROP chains).
8. mmap'ing file offset 0xe2000 when loading the fourth segment will
   include 0x730 bytes (0xe0800 + 0x1f30 - 0xe2000) from .plt, now
   mapped as readable (oops). Suddenly data from .plt is now readable
   (and thus scannable for gadgets for ROP chains).

All these oops' could be avoided if the linker placed .text+.plt at page
size aligned file offsets, which is what `-Wl,-z,separate-code` code
does.  After this patch, we have:

```
$ readelf -lSW $OUT/symbols/apex/com.android.runtime/lib64/bionic/libc.so
...
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000230 0x000230 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x041b34 0x041b34 R   0x1000
  LOAD           0x042000 0x0000000000042000 0x0000000000042000 0x0a0be0 0x0a0be0   E 0x1000
  LOAD           0x0e3000 0x00000000000e3000 0x00000000000e3000 0x006720 0x006720 RW  0x1000
```

In the future, we could go back to tightly packing segments in the
binary if the runtime loader was improved to detect the previously
stated problem, and `memset` over the problematic ranges of the freshly
`mmap`ed pages (implying additional startup cost for reduced binary
size). This might save ~6 KB from each native binary, which adds up to
~17 MB for an AOSP image.

Also, prefer
-Wl,--execute-only
rather than
-Wl,-execute-only

Bug: 139945549
Bug: 146144180
Test: readelf -lSW $OUT/symbols/apex/com.android.runtime/lib64/bionic/libc.so
Change-Id: I64527e034ca3c71565ea52ed06f81f75d5216627
Reported-by: Ryan Prichard <rprichard@google.com>
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-12-16 09:55:37 -08:00
Automerger Merge Worker
d6b268fcb0 Merge "Optionally overwrite package value in test config." am: 9b1084f9b9 am: 73a0b33360
Change-Id: I8b3376946e5c556e52df68a478c3cbcaadb5e203
2019-12-16 17:26:57 +00:00
Jaewoong Jung
73a0b33360 Merge "Optionally overwrite package value in test config."
am: 9b1084f9b9

Change-Id: I7be612d317e79a00d430009ec8d2f352469c6cf9
2019-12-16 09:13:26 -08:00
Jaewoong Jung
9b1084f9b9 Merge "Optionally overwrite package value in test config." 2019-12-16 17:10:18 +00:00
Automerger Merge Worker
4a65ce22ca Fix duplicate sentence in visibility documentation am: f56f74be4a am: ef76ca7f43
Change-Id: I044902bbd9ff87070d942b41297cb93d532ac360
2019-12-16 14:17:59 +00:00
Anton Hansson
ef76ca7f43 Fix duplicate sentence in visibility documentation
am: f56f74be4a

Change-Id: I7a67434bfdd1b9f67869044ea96c49743ad3abd6
2019-12-16 06:09:34 -08:00
Jooyung Han
f21c797f38 Support apps attribute in apex_defaults
Adding overridableProperties to apex_defaults as well.

Bug: 146217017
Test: m
Change-Id: I51182fec25ee589fea4006164c4dd69acc5ba67d
2019-12-16 13:36:34 +00:00
Anton Hansson
f56f74be4a Fix duplicate sentence in visibility documentation
This paragraph was duplicated.

Test: treehugger
Change-Id: I6057b96e310ac0ebf8f6f2a86f93efafd189579e
2019-12-16 11:39:17 +00:00
Automerger Merge Worker
09508fa7c9 Merge "ignore apex_available for host variants" am: 7829a9bf9e am: a838ea2fbc
Change-Id: I9a46c35dee5f271d9f1e8415c9b8847b9f467cf7
2019-12-16 10:31:12 +00:00
Automerger Merge Worker
00b7c93177 Merge "java libs that isn't installable is gracefully rejected" am: c829ff371e am: c3aa31b02c
Change-Id: I99233bc652c2b9829dbf4dcd975c55214fe45bc9
2019-12-16 10:30:55 +00:00
Jiyong Park
a838ea2fbc Merge "ignore apex_available for host variants"
am: 7829a9bf9e

Change-Id: I80067f1f149a812fd06bfbe10349fb0d0743ef29
2019-12-16 02:24:25 -08:00
Treehugger Robot
7829a9bf9e Merge "ignore apex_available for host variants" 2019-12-16 10:21:35 +00:00
Jiyong Park
c3aa31b02c Merge "java libs that isn't installable is gracefully rejected"
am: c829ff371e

Change-Id: I42430cc748b0109ecb683dc227c07b906c2a1f9d
2019-12-16 02:09:23 -08:00
Treehugger Robot
c829ff371e Merge "java libs that isn't installable is gracefully rejected" 2019-12-16 09:56:13 +00:00
Jiyong Park
479321dc34 java libs that isn't installable is gracefully rejected
... rather than causing soong panic.

Bug: 146197571
Test: m (apex_test amended)
Change-Id: I3679a4e3041527533c1c05d54f3aa514abd6095b
2019-12-16 15:59:54 +09:00
Jiyong Park
2812df4edb Avoid duplicated classes for boot dex jars
When a boot classpath java library is directly or indirectly included in
APEXes, multiple variant of the library exist. When running the
hiddenapi tool, we need to eliminate the duplication, otherwise the tool
will complain.

Previously, we simply choose the platform variant of the java library
among the multiple variants. However, if the java library is marked not
available for the platform (i.e. "//apex_available:platform" is not in
the apex_available property), the platform variant does not exist and
thus it is not fed into the hiddenapi tool, which causes missing
references in the tool.

To solve the problem, the platform variant is selected only for the java
libs that are available for the platform. For those libs that are not
available for the platform, we choose one variant of it using a
heuristic; skip testing APEXes and choose com.android.art.release among
the com.android.art.* variants.

Bug: 128708192
Test: m

Change-Id: I33bf297eb3029696ae3504a011486210708fb2c2
2019-12-16 15:19:13 +09:00
Jiyong Park
505221f6e0 ignore apex_available for host variants
The main purpose of apex_available is to prevent a module from being
installed to the system partition (or being statically linked to
something that is installed to the system partition). It's not the goal
to prevent host tools from using the modules.

However, since both host and device variants are not mutated for
platform when the module is not available to platform, the host tools
that depends on those modules couldn't be built. To solve the problem,
the platform variation is NOT skipped for the host variants.

Bug: 128708192
Test: m

Change-Id: I1d662cd6d165581f344138d872329a15bfc43d17
2019-12-16 15:19:13 +09:00
Automerger Merge Worker
36774df64e fix: LOCAL_PATH for modules included in APEX is wrong am: 1833ceff09 am: 2bd71e4da1
Change-Id: I5dd303c518478b0a9216511c521cebabc45b4d6b
2019-12-16 04:32:17 +00:00
Jiyong Park
2bd71e4da1 fix: LOCAL_PATH for modules included in APEX is wrong
am: 1833ceff09

Change-Id: I9ff5f1726806e35ae841c4026646ada7e0570c2b
2019-12-15 20:20:07 -08:00
Jiyong Park
1833ceff09 fix: LOCAL_PATH for modules included in APEX is wrong
This change fixes a bug that LOCAL_PATH for modules included in an APEX
is set to the path of the APEX bundle, not to the path of the embedded
module. For example, LOCAL_PATH of libconscrypt included in
com.android.adbd was set to /system/core/adb instead of
/external/boringssl. This caused a problem that NOTICE file in
/external/boringssl is not tagged to libconscrypt, but the NOTICE file
for adbd is.

Fixing the problem by recording the module directories of the included
modules and emitting it in LOCAL_PATH.

Bug: 145347092
Test: Settings -> About Phone -> Legal Information -> Third-party
license. The license for /apex/com.android.adbd/lib64/libconscrypt.so is
OpenSSL.

Change-Id: I76f1830d5a10af63fa74dcc2a42730ffabb8c4ed
2019-12-16 10:53:44 +09:00
Automerger Merge Worker
70d970fa22 Merge "Switch the mac back to toybox xargs." am: 0f41daf682 am: 86aad618f3
Change-Id: Ia1185023c366bdcca1a52c432fdb3e334f85c525
2019-12-15 16:51:02 +00:00
Elliott Hughes
86aad618f3 Merge "Switch the mac back to toybox xargs."
am: 0f41daf682

Change-Id: I1d39656361560d650b946207470a5532b402787f
2019-12-15 08:38:03 -08:00
Treehugger Robot
0f41daf682 Merge "Switch the mac back to toybox xargs." 2019-12-15 16:35:05 +00:00
Automerger Merge Worker
67876e8d8d Merge "Remove obsolete copy headers" am: 950bf327b7 am: d476fc7dbe
Change-Id: Ifd92ccae2f019a6417423b7e2f4f647169ad6dec
2019-12-15 00:21:15 +00:00
Dan Willemsen
d476fc7dbe Merge "Remove obsolete copy headers"
am: 950bf327b7

Change-Id: Ibcccd4de27bdb8e2425632872a40c02e21a55e00
2019-12-14 16:08:10 -08:00
Dan Willemsen
950bf327b7 Merge "Remove obsolete copy headers" 2019-12-15 00:04:15 +00:00
Automerger Merge Worker
b0a704e865 Merge "Decouple addition of new sdk member types from sdk code" am: 0558ecce51 am: d32b891ff3
Change-Id: I04782158204c35fcc74a6af3472599a4474ed5d3
2019-12-14 15:09:49 +00:00
Paul Duffin
d32b891ff3 Merge "Decouple addition of new sdk member types from sdk code"
am: 0558ecce51

Change-Id: Ic1da6424bffada70a0e69bb6605495f45a2f71b2
2019-12-14 07:00:58 -08:00
Treehugger Robot
0558ecce51 Merge "Decouple addition of new sdk member types from sdk code" 2019-12-14 14:57:42 +00:00
Colin Cross
7113d20774 Use empty string for core image variant
Use the empty string for the core image variant so that modules
added to imageMutator do not change their build directory.

Bug: 142286466
Test: m checkbuild
Change-Id: Ida4534d9a4d6176236aaa480fed359ce27acfaa1
Merged-In: Ida4534d9a4d6176236aaa480fed359ce27acfaa1
(cherry picked from commit 72d685ee7f45e5393be44ae4159edf083ac918de)
2019-12-13 20:44:36 -08:00
Dan Willemsen
7842826f49 Remove obsolete copy headers
When LOCAL_COPY_HEADER lines are removed, we just removed the copy rule,
we didn't actually remove the old header, so C/C++ files could still
include the old headers during incremental builds.

While we do consider LOCAL_COPY_HEADERS as near-obsolet, and it'll
disappear as we move everything over to Soong, this could produce some
unfortunate incremental build results while people are attempting to
remove them.

Fix this by ensuring that only the files currently listed in
LOCAL_COPY_HEADERS exist in TARGET_OUT_HEADERS after we run Kati.

Test: Remove a LOCAL_COPY_HEADERS entry; see the header removed
Change-Id: I817305703a6996d50490d552623d7df019b608c9
2019-12-13 19:38:23 -08:00
Automerger Merge Worker
77a069fe7f Merge "Add "legacy_android10_support" to "apex"" am: ac68248051 am: 36c5f9e811
Change-Id: I7edee927894958268ca20653d803a1398fb07f65
2019-12-14 02:28:18 +00:00
Jooyung Han
36c5f9e811 Merge "Add "legacy_android10_support" to "apex""
am: ac68248051

Change-Id: If788f448a844909ec4f0fe1f2f38cd53e3d43921
2019-12-13 18:13:33 -08:00