blob: 90daf30eb4aca40dceafc2a495dbd94502130726 [file] [log] [blame]
Torne (Richard Coles)012cb452014-02-06 14:34:21 +00001/*
2 * Copyright (C) 2014 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 __ANDROID_DLEXT_H__
18#define __ANDROID_DLEXT_H__
19
20#include <stddef.h>
David 'Digit' Turneraad1a392014-11-18 12:21:55 +010021#include <stdint.h>
Torne (Richard Coles)012cb452014-02-06 14:34:21 +000022#include <sys/cdefs.h>
David 'Digit' Turneraad1a392014-11-18 12:21:55 +010023#include <sys/types.h> /* for off64_t */
Torne (Richard Coles)012cb452014-02-06 14:34:21 +000024
25__BEGIN_DECLS
26
27/* bitfield definitions for android_dlextinfo.flags */
28enum {
Torne (Richard Coles)12bbb912014-02-06 14:34:21 +000029 /* When set, the reserved_addr and reserved_size fields must point to an
30 * already-reserved region of address space which will be used to load the
31 * library if it fits. If the reserved region is not large enough, the load
32 * will fail.
33 */
34 ANDROID_DLEXT_RESERVED_ADDRESS = 0x1,
35
36 /* As DLEXT_RESERVED_ADDRESS, but if the reserved region is not large enough,
37 * the linker will choose an available address instead.
38 */
39 ANDROID_DLEXT_RESERVED_ADDRESS_HINT = 0x2,
40
Torne (Richard Coles)183ad9d2014-02-27 13:18:00 +000041 /* When set, write the GNU RELRO section of the mapped library to relro_fd
42 * after relocation has been performed, to allow it to be reused by another
43 * process loading the same library at the same address. This implies
44 * ANDROID_DLEXT_USE_RELRO.
45 */
46 ANDROID_DLEXT_WRITE_RELRO = 0x4,
47
48 /* When set, compare the GNU RELRO section of the mapped library to relro_fd
49 * after relocation has been performed, and replace any relocated pages that
50 * are identical with a version mapped from the file.
51 */
52 ANDROID_DLEXT_USE_RELRO = 0x8,
53
Dmitriy Ivanov04dc91a2014-07-01 14:10:16 -070054 /* Instruct dlopen to use library_fd instead of opening file by name.
55 * The filename parameter is still used to identify the library.
56 */
57 ANDROID_DLEXT_USE_LIBRARY_FD = 0x10,
58
Dmitriy Ivanova6c12792014-10-21 12:09:18 -070059 /* If opening a library using library_fd read it starting at library_fd_offset.
Dmitriy Ivanov07e5bc12014-10-03 17:52:44 -070060 * This flag is only valid when ANDROID_DLEXT_USE_LIBRARY_FD is set.
61 */
62
Dmitriy Ivanova6c12792014-10-21 12:09:18 -070063 ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20,
Dmitriy Ivanov07e5bc12014-10-03 17:52:44 -070064
Torne (Richard Coles)012cb452014-02-06 14:34:21 +000065 /* Mask of valid bits */
Torne (Richard Coles)12bbb912014-02-06 14:34:21 +000066 ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS |
Torne (Richard Coles)183ad9d2014-02-27 13:18:00 +000067 ANDROID_DLEXT_RESERVED_ADDRESS_HINT |
68 ANDROID_DLEXT_WRITE_RELRO |
Dmitriy Ivanov04dc91a2014-07-01 14:10:16 -070069 ANDROID_DLEXT_USE_RELRO |
Dmitriy Ivanov07e5bc12014-10-03 17:52:44 -070070 ANDROID_DLEXT_USE_LIBRARY_FD |
Dmitriy Ivanova6c12792014-10-21 12:09:18 -070071 ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET,
Torne (Richard Coles)012cb452014-02-06 14:34:21 +000072};
73
74typedef struct {
Dmitriy Ivanov3a8646f2014-07-08 11:21:56 -070075 uint64_t flags;
Torne (Richard Coles)12bbb912014-02-06 14:34:21 +000076 void* reserved_addr;
77 size_t reserved_size;
Torne (Richard Coles)183ad9d2014-02-27 13:18:00 +000078 int relro_fd;
Dmitriy Ivanov04dc91a2014-07-01 14:10:16 -070079 int library_fd;
Dmitriy Ivanova6c12792014-10-21 12:09:18 -070080 off64_t library_fd_offset;
Torne (Richard Coles)012cb452014-02-06 14:34:21 +000081} android_dlextinfo;
82
83extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);
84
85__END_DECLS
86
87#endif /* __ANDROID_DLEXT_H__ */