aboutsummaryrefslogtreecommitdiff
path: root/reloc_elf_unittest.cc
AgeCommit message (Collapse)Author
2021-08-03[Zucchini] Disassemblers: Fix abs32 width for ELF; cleanup Traits template ↵Samuel Huang
param. Previously DisassemblerElfIntel<TRAITS>::ParseExecSection() passes a hard-coded 4 to Abs32GapFinder's |abs32_width| CTOR param. This is wrong for X64, which has abs32 pointer width of 8 bytes. This can lead to lower quality rel32 extraction. This CL fixes the above by replacing 4 with Traits::kVAWidth, and also cleans up TRAITS / Traits template parameter for Disassembler: * For template param, "template <class TRAITS>" is used throughout. * This means function params needs to use TRAITS. * For usage, each Disassembler class with TRAITS declares using Traits = TRAITS; (and variant) and uses Traits in the body of all functions. Reason: Specialized derive classes won't have TRAITS available , so: * Function params can use DisassemblerBase::Traits. * Function bodies can use Traits. * For consistency, even if TRAITS is available, still use Traits. Bug: 1233831 Change-Id: Ie796c867fb238eca462b2fb6b4e68a965996c25a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3063919 Commit-Queue: Samuel Huang <huangs@chromium.org> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/master@{#908261} NOKEYCHECK=True GitOrigin-RevId: 294860c47cd3678c46422ce57da366724e1dc629
2021-07-25Add explicit type conversions where necessary: components/Peter Kasting
These are cases that are implicitly narrowing today, and must do so explicitly in order to enable -Wc++11-narrowing. No behavior change intended. Bug: 1216696 Change-Id: Ic8f194bb0ab9a247d3e84cc59a687285cdb96d48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2947886 Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#890878} NOKEYCHECK=True GitOrigin-RevId: 379c52be13901beae4f773fe9e8054ad42a186c4
2021-07-25components: Replace base::Optional and friends with absl counterpartsAnton Bikineev
This replaces: - base::Optional -> absl::optional - include "base/optional.h" -> include "third_party/abseil-cpp/absl/types/optional.h" - base::nullopt -> absl::nullopt - base::make_optional -> absl::make_optional Bug: 1202909 Change-Id: If697b7bf69b199c1796f873eedca3359cdb48c64 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897151 Commit-Queue: Anton Bikineev <bikineev@chromium.org> Owners-Override: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/master@{#883296} NOKEYCHECK=True GitOrigin-RevId: 1156b5f891de178171e71b9221a96bef1ced3d3b
2021-07-25[Zucchini] Fix 64-bit ELF reloc code failing to reject references that ↵Samuel Huang
straddle EOF. RelocReaderElf is supposed to reject relocs that refers to an abs32 reference that lies outside the image. This should include references whose offset is in the image, but whose body "straddles" image boundary. Turns out the reference width for this check was hard-coded to 4, and on ELF64, this allows 8-byte wide references to sneak by the check (which leads to check failure down the road). This CL fixes the above, while adding new unit tests (with refactoring). Meanwhile, Win32 reloc extraction works a little differently, and already handles the above issue. Bug: 1028892 Change-Id: I746c1a2d8114a429f74d9c0605f50044e05d76be Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013463 Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org> Commit-Queue: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#734488} NOKEYCHECK=True GitOrigin-RevId: 0b8add5192efb2b283f381fcd9a590e655df2f35
2021-07-25[Zucchini] Update code formatting.Samuel Huang
This CL ensures that all Zucchini source files pass 'git cl lint' and 'git cl format'. The following is applied: * Add all source files into a CL. * Run 'git cl format', and manually update files that don't pass. * Revert unchanged files. * Run 'clang-format' on all source files. Change-Id: I8f5b7ca92df2400b09f0ca008af3455418e6ba12 Reviewed-on: https://chromium-review.googlesource.com/c/1400951 Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Commit-Queue: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#620810} NOKEYCHECK=True GitOrigin-RevId: 3c6f6bd73a1b7c9c686462f35e681d2921df649e
2021-07-25[Zucchini] Create elf types and utils.Etienne Pierre-Doray
Creates types and utility class to manipulate ELF header format and relocation references. BufferView: :modify() was also added. Change-Id: Iacec212a2fb2f8a6c85d551eed4b8e0a84926d89 Reviewed-on: https://chromium-review.googlesource.com/1136846 Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#578034} NOKEYCHECK=True GitOrigin-RevId: 320f7d9d2cff9702e632af296867bf6ce7b14f8b