xref: /aosp_15_r20/platform_testing/utils/shell-as/elf-utils.h (revision dd0948b35e70be4c0246aabd6c72554a5eb8b22a)
1*dd0948b3SAndroid Build Coastguard Worker /*
2*dd0948b3SAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
3*dd0948b3SAndroid Build Coastguard Worker  *
4*dd0948b3SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*dd0948b3SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*dd0948b3SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*dd0948b3SAndroid Build Coastguard Worker  *
8*dd0948b3SAndroid Build Coastguard Worker  *     http://www.apache.org/licenses/LICENSE-2.0
9*dd0948b3SAndroid Build Coastguard Worker  *
10*dd0948b3SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*dd0948b3SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*dd0948b3SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*dd0948b3SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*dd0948b3SAndroid Build Coastguard Worker  * limitations under the License.
15*dd0948b3SAndroid Build Coastguard Worker  */
16*dd0948b3SAndroid Build Coastguard Worker 
17*dd0948b3SAndroid Build Coastguard Worker #ifndef SHELL_AS_ELF_H_
18*dd0948b3SAndroid Build Coastguard Worker #define SHELL_AS_ELF_H_
19*dd0948b3SAndroid Build Coastguard Worker 
20*dd0948b3SAndroid Build Coastguard Worker #include <sys/types.h>
21*dd0948b3SAndroid Build Coastguard Worker 
22*dd0948b3SAndroid Build Coastguard Worker namespace shell_as {
23*dd0948b3SAndroid Build Coastguard Worker 
24*dd0948b3SAndroid Build Coastguard Worker // Sets entry_address to the process's entry point.
25*dd0948b3SAndroid Build Coastguard Worker //
26*dd0948b3SAndroid Build Coastguard Worker // This method assumes that PIE binaries are executing with ADDR_NO_RANDOMIZE.
27*dd0948b3SAndroid Build Coastguard Worker //
28*dd0948b3SAndroid Build Coastguard Worker // The is_arm_mode flag is set to true IFF the architecture is 32bit ARM and the
29*dd0948b3SAndroid Build Coastguard Worker // expected instruction set for code located at the entry address is not-thumb.
30*dd0948b3SAndroid Build Coastguard Worker // It is false for all other cases.
31*dd0948b3SAndroid Build Coastguard Worker bool GetElfEntryPoint(const pid_t process_id, uint64_t* entry_address,
32*dd0948b3SAndroid Build Coastguard Worker                       bool* is_arm_mode);
33*dd0948b3SAndroid Build Coastguard Worker }  // namespace shell_as
34*dd0948b3SAndroid Build Coastguard Worker 
35*dd0948b3SAndroid Build Coastguard Worker #endif  // SHELL_AS_ELF_H_
36