blob: 048d78e444113a6adfba6576dac4f9bcd1527113 [file] [log] [blame]
Hristo Bojinovdb314d62010-08-02 10:29:49 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _MINELF_RETOUCH
18#define _MINELF_RETOUCH
19
20#include <stdbool.h>
21#include <sys/types.h>
22
23typedef struct {
24 char tag[8]; /* "RETOUCH ", not zero-terminated */
25 uint32_t blob_size; /* in bytes, located right before this struct */
26} retouch_info_t __attribute__((packed));
27
28// Retouch a file. Use CACHED_SOURCE_TEMP to store a copy.
29bool retouch_one_library(const char *binary_name,
30 const char *binary_sha1,
31 int32_t retouch_offset,
32 int32_t *retouch_offset_override);
33
34#define RETOUCH_DONT_MASK 0
35#define RETOUCH_DO_MASK 1
36
37#define RETOUCH_DATA_ERROR 0 // This is bad. Should not happen.
38#define RETOUCH_DATA_MATCHED 1 // Up to an uniform random offset.
39#define RETOUCH_DATA_MISMATCHED 2 // Partially randomized, or total mess.
40#define RETOUCH_DATA_NOTAPPLICABLE 3 // Not retouched. Only when inferring.
41
42// Mask retouching in-memory. Used before apply_patch[_check].
43// Also used to determine status of retouching after a crash.
44//
45// If desired_offset is not NULL, then apply retouching instead,
46// and return that in retouch_offset.
47int retouch_mask_data(uint8_t *binary_object,
48 int32_t binary_size,
49 int32_t *desired_offset,
50 int32_t *retouch_offset);
51#endif