c77a0b3f9c
The linux kernel requires that the ELF interpreter (runtime linker) that's referenced by PT_INTERP be either an absolute path, or a relative path from the current working directory. We'd prefer a relative path from the binary, similarly to how we handle looking up shared libraries, but that's not supported. Instead, extract the load sections from the runtime linker ELF binary and embed them into each host bionic binary, omitting the PT_INTERP declaration. The kernel will treat it as a static binary, and we'll use a special entry point (linker_wrapper) to fix up the arguments passed by the kernel before jumping to the embedded linker. From the linker's point of view, it looks like the kernel loaded the linker like normal. Bug: 31559095 Test: Enable host bionic, out/soong/host/linux_bionic-x86/nativetest64/libdemangle_test/libdemangle_test Change-Id: I8d0aea9790b5e86fcc3ea6e2d00cfa33907e2853
20 lines
718 B
Text
20 lines
718 B
Text
// Copyright 2017 Google Inc. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
blueprint_go_binary {
|
|
name: "extract_linker",
|
|
srcs: ["main.go"],
|
|
testSrcs: ["main_test.go"],
|
|
}
|
|
|