Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

79 lines
2.6 KiB
C++

//===-- TestSectionFileSize.cpp -------------------------------------------===//
//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
#include "TestingSupport/SubsystemRAII.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/CallFrameInfo.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "llvm/Testing/Support/Error.h"
using namespace lldb_private;
using namespace lldb;
class SectionSizeTest : public testing::Test {
SubsystemRAII<FileSystem, ObjectFilePECOFF> subsystems;
};
TEST_F(SectionSizeTest, NoAlignmentPadding) {
llvm::Expected<TestFile> ExpectedFile = TestFile::fromYaml(
R"(
--- !COFF
OptionalHeader:
SectionAlignment: 4096
FileAlignment: 512
header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
sections:
- Name: swiftast
VirtualSize: 496
SizeOfRawData: 512
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
SectionData: 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000
symbols: []
...
)");
ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
ModuleSP module_sp = std::make_shared<Module>(ExpectedFile->moduleSpec());
ObjectFile *object_file = module_sp->GetObjectFile();
ASSERT_NE(object_file, nullptr);
SectionList *section_list = object_file->GetSectionList();
ASSERT_NE(section_list, nullptr);
SectionSP swiftast_section;
size_t section_count = section_list->GetNumSections(0);
for (size_t i = 0; i < section_count; ++i) {
SectionSP section_sp = section_list->GetSectionAtIndex(i);
if (section_sp->GetName() == "swiftast") {
swiftast_section = section_sp;
break;
}
}
ASSERT_NE(swiftast_section.get(), nullptr);
DataExtractor section_data;
ASSERT_NE(object_file->ReadSectionData(swiftast_section.get(),
section_data),
(size_t)0);
// Check that the section data size is equal to VirtualSize (496)
// without the zero padding, instead of SizeOfRawData (512).
EXPECT_EQ(section_data.GetByteSize(), (uint64_t)496);
}