// object.h -- support for an object file for linking in gold -*- C++ -*-
-// Copyright (C) 2006-2018 Free Software Foundation, Inc.
+// Copyright (C) 2006-2021 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
{
section_size_type size;
elfcpp::Elf_Xword flag;
+ uint64_t addralign;
const unsigned char* contents;
};
typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
const char* names, section_size_type names_size,
Object* obj, bool decompress_if_needed);
+// Osabi represents the EI_OSABI field from the ELF header.
+
+class Osabi
+{
+ public:
+ Osabi(unsigned char ei_osabi)
+ : ei_osabi_(static_cast<elfcpp::ELFOSABI>(ei_osabi))
+ { }
+
+ bool
+ has_shf_retain(elfcpp::Elf_Xword sh_flags) const
+ {
+ switch (this->ei_osabi_)
+ {
+ case elfcpp::ELFOSABI_GNU:
+ case elfcpp::ELFOSABI_FREEBSD:
+ return (sh_flags & elfcpp::SHF_GNU_RETAIN) != 0;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ elfcpp::Elf_Xword
+ ignored_sh_flags() const
+ {
+ switch (this->ei_osabi_)
+ {
+ case elfcpp::ELFOSABI_GNU:
+ case elfcpp::ELFOSABI_FREEBSD:
+ return elfcpp::SHF_GNU_RETAIN;
+ default:
+ break;
+ }
+ return 0;
+ }
+
+ private:
+ elfcpp::ELFOSABI ei_osabi_;
+};
+
// Object is an abstract base class which represents either a 32-bit
// or a 64-bit input object. This can be a regular object file
// (ET_REL) or a shared object (ET_DYN).
bool
section_is_compressed(unsigned int shndx,
- section_size_type* uncompressed_size) const
+ section_size_type* uncompressed_size,
+ elfcpp::Elf_Xword* palign = NULL) const
{
if (this->compressed_sections_ == NULL)
return false;
{
if (uncompressed_size != NULL)
*uncompressed_size = p->second.size;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return true;
}
return false;
// by the caller.
const unsigned char*
decompressed_section_contents(unsigned int shndx, section_size_type* plen,
- bool* is_cached);
+ bool* is_cached, uint64_t* palign = NULL);
// Discard any buffers of decompressed sections. This is done
// at the end of the Add_symbols task.
e_type() const
{ return this->e_type_; }
+ // Return the EI_OSABI.
+ const Osabi&
+ osabi() const
+ { return this->osabi_; }
+
// Return the number of symbols. This is only valid after
// Object::add_symbols has been called.
unsigned int
// General access to the ELF file.
elfcpp::Elf_file<size, big_endian, Object> elf_file_;
+ // The EI_OSABI.
+ const Osabi osabi_;
// Type of ELF file (ET_REL or ET_EXEC). ET_EXEC files are allowed
// as input files only for the --just-symbols option.
int e_type_;