1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "dynlink.h" 17 18 #define CFI_SUCCESS 0 19 #define CFI_FAILED -1 20 /* Define LIBRARY_ALIGNMENT to balance the size of CFI shadow and the number of DSOs that each process can load. 21 * The LIBRARY_ALIGNMENT is use to calculate the start address of a DSO. Each DSO should be in the different 22 * LIBRARY_ALIGNMENT memory range so that each DSO can be well mapped to the CFI shadow. 23 */ 24 #define LIBRARY_ALIGNMENT_BITS 18 25 #define LIBRARY_ALIGNMENT (1UL << LIBRARY_ALIGNMENT_BITS) 26 27 /* map all the dso and the dependents to cfi shadow */ 28 int init_cfi_shadow(struct dso *dso_list, struct dso *ldso, struct dso *app, struct dso *vdso); 29 /* map a dso and the dependents to cfi shadow */ 30 int map_dso_to_cfi_shadow(struct dso *dso); 31 /* unmap a dso from cfi shadow */ 32 void unmap_dso_from_cfi_shadow(struct dso *dso);