Skip to content

Commit

Permalink
More const correctness in the ELF generation path
Browse files Browse the repository at this point in the history
Fix build22.bat syntax error

Remove some unused fields from elf_section

Signed-off-by: Sonal Santan <sonal.santan@amd.com>
  • Loading branch information
sonals committed Feb 28, 2025
1 parent 7cdb18a commit 99a35e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build/build22.bat
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ IF DEFINED MSVC_PARALLEL_JOBS ( SET LOCAL_MSVC_PARALLEL_JOBS=%MSVC_PARALLEL_JOBS
) else (
echo Unknown option: %1
goto Help
)))))))))
))))))))))
shift
goto parseArgs

Expand Down
10 changes: 5 additions & 5 deletions src/cpp/aiebu/src/elf/elfwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ namespace aiebu {

ELFIO::section*
elf_writer::
add_section(elf_section& data)
add_section(const elf_section& data)
{
// add section
ELFIO::section* sec = m_elfio.sections.add(data.get_name());
sec->set_type(data.get_type());
sec->set_flags(data.get_flags());
sec->set_addr_align(data.get_align());
std::vector<uint8_t> buf = data.get_buffer();
const std::vector<uint8_t> buf = data.get_buffer();

if(buf.size())
sec->set_data(reinterpret_cast<char*>(buf.data()), static_cast<ELFIO::Elf_Word>(buf.size()));
sec->set_data(reinterpret_cast<const char*>(buf.data()), static_cast<ELFIO::Elf_Word>(buf.size()));
//sec->set_info( data.get_info() );
if (!data.get_link().empty())
{
Expand All @@ -29,7 +29,7 @@ add_section(elf_section& data)

ELFIO::segment*
elf_writer::
add_segment(elf_segment& data)
add_segment(const elf_segment& data)
{
// add segment
ELFIO::segment* seg = m_elfio.segments.add();
Expand Down Expand Up @@ -179,7 +179,7 @@ finalize()

void
elf_writer::
add_text_data_section(std::vector<writer>& mwriter, std::vector<symbol>& syms)
add_text_data_section(const std::vector<writer>& mwriter, std::vector<symbol>& syms)
{
for(auto buffer : mwriter)
{
Expand Down
14 changes: 5 additions & 9 deletions src/cpp/aiebu/src/elf/elfwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class elf_section
int m_type;
int m_flags;
int m_version;
uint64_t m_size;
uint64_t m_offset;
uint64_t m_align;
int m_info;
std::string m_link;
Expand All @@ -40,8 +38,6 @@ class elf_section
HEADER_ACCESS_GET_SET(int, version);
HEADER_ACCESS_GET_SET(int, flags);
HEADER_ACCESS_GET_SET(int, info);
HEADER_ACCESS_GET_SET(uint64_t, size);
HEADER_ACCESS_GET_SET(uint64_t, offset);
HEADER_ACCESS_GET_SET(uint64_t, align);
HEADER_ACCESS_GET_SET(std::vector<uint8_t>, buffer);
HEADER_ACCESS_GET_SET(std::string, link);
Expand All @@ -54,8 +50,8 @@ class elf_segment
int m_flags;
uint64_t m_vaddr = 0x0;
uint64_t m_paddr = 0x0;
int m_filesz;
int m_memsz;
int m_filesz = 0;
int m_memsz = 0;
uint64_t m_align;
std::string m_link;
public:
Expand All @@ -75,14 +71,14 @@ class elf_writer
ELFIO::elfio m_elfio;
uid_md5 m_uid;

ELFIO::section* add_section(elf_section& data);
ELFIO::segment* add_segment(elf_segment& data);
ELFIO::section* add_section(const elf_section& data);
ELFIO::segment* add_segment(const elf_segment& data);
ELFIO::string_section_accessor add_dynstr_section();
void add_dynsym_section(ELFIO::string_section_accessor* stra, std::vector<symbol>& syms);
void add_reldyn_section(std::vector<symbol>& syms);
void add_dynamic_section_segment();
std::vector<char> finalize();
void add_text_data_section(std::vector<writer>& mwriter, std::vector<symbol>& syms);
void add_text_data_section(const std::vector<writer>& mwriter, std::vector<symbol>& syms);
void add_note(ELFIO::Elf_Word type, const std::string& name, const std::vector<char>& dec);

public:
Expand Down

0 comments on commit 99a35e7

Please sign in to comment.