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

141 lines
4.2 KiB
C++

// reduced_debug_output.h -- reduce debugging information -*- C++ -*-
// Copyright (C) 2008-2024 Free Software Foundation, Inc.
// Written by Caleb Howe <cshowe@google.com>.
// This file is part of gold.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
// Reduce the size of the debug sections by emitting only debug line number
// information. We still need to emit skeleton debug_info and debug_abbrev
// sections for standard tools to parse the debug information correctly. These
// classes remove all debug information entries from the .debug_info section
// except for those describing compilation units as these DIEs contain
// references to the debug line information needed by most parsers.
#ifndef GOLD_REDUCED_DEBUG_OUTPUT_H
#define GOLD_REDUCED_DEBUG_OUTPUT_H
#include <map>
#include <utility>
#include <vector>
#include "output.h"
namespace gold
{
class Output_reduced_debug_abbrev_section : public Output_section
{
public:
Output_reduced_debug_abbrev_section(const char* name, elfcpp::Elf_Word flags,
elfcpp::Elf_Xword type)
: Output_section(name, flags, type), sized_(false),
abbrev_count_(0), failed_(false)
{ this->set_requires_postprocessing(); }
unsigned char* get_new_abbrev(uint64_t* abbrev_number,
uint64_t abbrev_offset);
protected:
// Set the final data size.
void
set_final_data_size();
// Write out the new debug abbreviations
void
do_write(Output_file*);
private:
void
failed(std::string reason)
{
gold_warning("%s", reason.c_str());
failed_ = true;
}
// The reduced debug abbreviations
std::vector<unsigned char> data_;
// We map the abbreviation table offset and abbreviation number of the
// old abbreviation to the number and size of the new abbreviation.
std::map<std::pair<uint64_t, uint64_t>,
std::pair<uint64_t, uint64_t> > abbrev_mapping_;
bool sized_;
// The count of abbreviations in the output data
int abbrev_count_;
// Whether or not the debug reduction has failed for any reason
bool failed_;
};
class Output_reduced_debug_info_section : public Output_section
{
public:
Output_reduced_debug_info_section(const char* name, elfcpp::Elf_Word flags,
elfcpp::Elf_Xword type)
: Output_section(name, flags, type), failed_(false)
{ this->set_requires_postprocessing(); }
void
set_abbreviations(Output_reduced_debug_abbrev_section* abbrevs)
{ associated_abbrev_ = abbrevs; }
protected:
// Set the final data size.
void
set_final_data_size();
// Write out the new debug info
void
do_write(Output_file*);
private:
void
failed(std::string reason)
{
gold_warning("%s", reason.c_str());
this->failed_ = true;
}
// Given a pointer to the beginning of a die and the beginning of the
// associated abbreviation fills in die_end with the end of the information
// entry. If successful returns true. Get_die_end also takes a pointer to
// the end of the buffer containing the die. If die_end would be beyond the
// end of the buffer, or if an unsupported dwarf form is encountered returns
// false.
bool
get_die_end(unsigned char* die, unsigned char* abbrev,
unsigned char** die_end, unsigned char* buffer_end,
int address_size, bool is64);
// The reduced debug info
std::vector<unsigned char> data_;
// Each debug info section needs to be associated with a debug abbrev section
Output_reduced_debug_abbrev_section* associated_abbrev_;
// Whether or not the debug reduction has failed for any reason
bool failed_;
};
} // End namespace gold.
#endif // !defined(GOLD_REDUCED_DEBUG_OUTPUT_H)