/*
* Copyright ( C ) 2017 The Android Open Source Project
*
* 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 .
*/
#include <gtest/gtest.h>
#include "base/macros.h"
#include "linker_patch.h"
namespace art HIDDEN {
namespace linker {
TEST(LinkerPatch, LinkerPatchOperators) {
const DexFile* dex_file1 = reinterpret_cast <const DexFile*>(1 );
const DexFile* dex_file2 = reinterpret_cast <const DexFile*>(2 );
LinkerPatch patches[] = {
LinkerPatch::IntrinsicReferencePatch(16 u, 3000 u, 1000 u),
LinkerPatch::IntrinsicReferencePatch(16 u, 3001 u, 1000 u),
LinkerPatch::IntrinsicReferencePatch(16 u, 3000 u, 1001 u),
LinkerPatch::IntrinsicReferencePatch(16 u, 3001 u, 1001 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file1, 3001 u, 1001 u), // Index 7.
LinkerPatch::RelativeMethodPatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::RelativeCodePatch(16 u, dex_file1, 1000 u),
LinkerPatch::RelativeCodePatch(16 u, dex_file1, 1001 u),
LinkerPatch::RelativeCodePatch(16 u, dex_file2, 1000 u),
LinkerPatch::RelativeCodePatch(16 u, dex_file2, 1001 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeTypePatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeStringPatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::StringBssEntryPatch(16 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::BakerReadBarrierBranchPatch(16 u, 0 u, 0 u),
LinkerPatch::BakerReadBarrierBranchPatch(16 u, 0 u, 1 u),
LinkerPatch::BakerReadBarrierBranchPatch(16 u, 1 u, 0 u),
LinkerPatch::BakerReadBarrierBranchPatch(16 u, 1 u, 1 u),
LinkerPatch::IntrinsicReferencePatch(32 u, 3000 u, 1000 u),
LinkerPatch::IntrinsicReferencePatch(32 u, 3001 u, 1000 u),
LinkerPatch::IntrinsicReferencePatch(32 u, 3000 u, 1001 u),
LinkerPatch::IntrinsicReferencePatch(32 u, 3001 u, 1001 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeMethodPatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::MethodBssEntryPatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::RelativeCodePatch(32 u, dex_file1, 1000 u),
LinkerPatch::RelativeCodePatch(32 u, dex_file1, 1001 u),
LinkerPatch::RelativeCodePatch(32 u, dex_file2, 1000 u),
LinkerPatch::RelativeCodePatch(32 u, dex_file2, 1001 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeTypePatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::TypeBssEntryPatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::RelativeStringPatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file1, 3000 u, 1000 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file1, 3001 u, 1000 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file1, 3000 u, 1001 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file1, 3001 u, 1001 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file2, 3000 u, 1000 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file2, 3001 u, 1000 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file2, 3000 u, 1001 u),
LinkerPatch::StringBssEntryPatch(32 u, dex_file2, 3001 u, 1001 u),
LinkerPatch::BakerReadBarrierBranchPatch(32 u, 0 u, 0 u),
LinkerPatch::BakerReadBarrierBranchPatch(32 u, 0 u, 1 u),
LinkerPatch::BakerReadBarrierBranchPatch(32 u, 1 u, 0 u),
LinkerPatch::BakerReadBarrierBranchPatch(32 u, 1 u, 1 u),
LinkerPatch::RelativeMethodPatch(16 u, dex_file1, 3001 u, 1001 u), // Same as patch at index 7.
};
constexpr size_t last_index = arraysize(patches) - 1 u;
for (size_t i = 0 ; i != arraysize(patches); ++i) {
for (size_t j = 0 ; j != arraysize(patches); ++j) {
bool expected = (i != last_index ? i : 7 u) == (j != last_index ? j : 7 u);
EXPECT_EQ(expected, patches[i] == patches[j]) << i << " " << j;
}
}
for (size_t i = 0 ; i != arraysize(patches); ++i) {
for (size_t j = 0 ; j != arraysize(patches); ++j) {
bool expected = (i != last_index ? i : 7 u) < (j != last_index ? j : 7 u);
EXPECT_EQ(expected, patches[i] < patches[j]) << i << " " << j;
}
}
}
} // namespace linker
} // namespace art
Messung V0.5 in Prozent C=90 H=95 G=92
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-29)
¤
*© Formatika GbR, Deutschland