Skip to content

Commit

Permalink
Put size and endianness in parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Lance Taylor committed Sep 26, 2007
1 parent 035df0a commit 34fe7f7
Show file tree
Hide file tree
Showing 15 changed files with 450 additions and 244 deletions.
4 changes: 2 additions & 2 deletions gold/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ Sort_commons<size>::operator()(const Symbol* pa, const Symbol* pb) const
void
Symbol_table::allocate_commons(const General_options& options, Layout* layout)
{
if (this->get_size() == 32)
if (parameters->get_size() == 32)
{
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
this->do_allocate_commons<32>(options, layout);
#else
gold_unreachable();
#endif
}
else if (this->get_size() == 64)
else if (parameters->get_size() == 64)
{
#if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
this->do_allocate_commons<64>(options, layout);
Expand Down
94 changes: 65 additions & 29 deletions gold/dynobj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,7 @@ Dynobj::elf_hash(const char* name)
// symbol table.

void
Dynobj::create_elf_hash_table(const Target* target,
const std::vector<Symbol*>& dynsyms,
Dynobj::create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
unsigned int local_dynsym_count,
unsigned char** pphash,
unsigned int* phashlen)
Expand Down Expand Up @@ -774,10 +773,24 @@ Dynobj::create_elf_hash_table(const Target* target,
* 4);
unsigned char* phash = new unsigned char[hashlen];

if (target->is_big_endian())
Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash, hashlen);
if (parameters->is_big_endian())
{
#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash,
hashlen);
#else
gold_unreachable();
#endif
}
else
Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash, hashlen);
{
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash,
hashlen);
#else
gold_unreachable();
#endif
}

*pphash = phash;
*phashlen = hashlen;
Expand Down Expand Up @@ -840,8 +853,7 @@ Dynobj::gnu_hash(const char* name)
// symbol table.

void
Dynobj::create_gnu_hash_table(const Target* target,
const std::vector<Symbol*>& dynsyms,
Dynobj::create_gnu_hash_table(const std::vector<Symbol*>& dynsyms,
unsigned int local_dynsym_count,
unsigned char** pphash,
unsigned int* phashlen)
Expand Down Expand Up @@ -890,37 +902,61 @@ Dynobj::create_gnu_hash_table(const Target* target,

// For the actual data generation we call out to a templatized
// function.
int size = target->get_size();
bool big_endian = target->is_big_endian();
int size = parameters->get_size();
bool big_endian = parameters->is_big_endian();
if (size == 32)
{
if (big_endian)
Dynobj::sized_create_gnu_hash_table<32, true>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
{
#ifdef HAVE_TARGET_32_BIG
Dynobj::sized_create_gnu_hash_table<32, true>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
#else
gold_unreachable();
#endif
}
else
Dynobj::sized_create_gnu_hash_table<32, false>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
{
#ifdef HAVE_TARGET_32_LITTLE
Dynobj::sized_create_gnu_hash_table<32, false>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
#else
gold_unreachable();
#endif
}
}
else if (size == 64)
{
if (big_endian)
Dynobj::sized_create_gnu_hash_table<64, true>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
{
#ifdef HAVE_TARGET_64_BIG
Dynobj::sized_create_gnu_hash_table<64, true>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
#else
gold_unreachable();
#endif
}
else
Dynobj::sized_create_gnu_hash_table<64, false>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
{
#ifdef HAVE_TARGET_64_LITTLE
Dynobj::sized_create_gnu_hash_table<64, false>(hashed_dynsyms,
dynsym_hashvals,
unhashed_dynsym_index,
pphash,
phashlen);
#else
gold_unreachable();
#endif
}
}
else
gold_unreachable();
Expand Down
4 changes: 2 additions & 2 deletions gold/dynobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Dynobj : public Object
// number of local dynamic symbols, which is the index of the first
// dynamic gobal symbol.
static void
create_elf_hash_table(const Target*, const std::vector<Symbol*>& dynsyms,
create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
unsigned int local_dynsym_count,
unsigned char** pphash,
unsigned int* phashlen);
Expand All @@ -66,7 +66,7 @@ class Dynobj : public Object
// of local dynamic symbols, which is the index of the first dynamic
// gobal symbol.
static void
create_gnu_hash_table(const Target*, const std::vector<Symbol*>& dynsyms,
create_gnu_hash_table(const std::vector<Symbol*>& dynsyms,
unsigned int local_dynsym_count,
unsigned char** pphash, unsigned int* phashlen);

Expand Down
7 changes: 3 additions & 4 deletions gold/ehframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ const int eh_frame_hdr_size = 4;

// Construct the exception frame header.

Eh_frame_hdr::Eh_frame_hdr(const Target* target,
Output_section* eh_frame_section)
Eh_frame_hdr::Eh_frame_hdr(Output_section* eh_frame_section)
: Output_section_data(4),
target_(target), eh_frame_section_(eh_frame_section)
eh_frame_section_(eh_frame_section)
{
}

Expand Down Expand Up @@ -109,7 +108,7 @@ Eh_frame_hdr::do_write(Output_file* of)
uint64_t eh_frame_hdr_address = this->address();
uint64_t eh_frame_offset = (eh_frame_address -
(eh_frame_hdr_address + 4));
if (this->target_->is_big_endian())
if (parameters->is_big_endian())
elfcpp::Swap<32, true>::writeval(oview + 4, eh_frame_offset);
else
elfcpp::Swap<32, false>::writeval(oview + 4, eh_frame_offset);
Expand Down
4 changes: 1 addition & 3 deletions gold/ehframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace gold
class Eh_frame_hdr : public Output_section_data
{
public:
Eh_frame_hdr(const Target*, Output_section* eh_frame_section);
Eh_frame_hdr(Output_section* eh_frame_section);

// Set the final data size.
void
Expand All @@ -53,8 +53,6 @@ class Eh_frame_hdr : public Output_section_data
do_write(Output_file*);

private:
// The output target.
const Target* target_;
// The .eh_frame section.
Output_section* eh_frame_section_;
};
Expand Down
4 changes: 1 addition & 3 deletions gold/gold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ queue_final_tasks(const General_options& options,

// Queue a task to write out everything else.
final_blocker->add_blocker();
workqueue->queue(new Write_data_task(layout, symtab,
input_objects->target(),
of, final_blocker));
workqueue->queue(new Write_data_task(layout, symtab, of, final_blocker));

// Queue a task to close the output file. This will be blocked by
// FINAL_BLOCKER.
Expand Down
Loading

0 comments on commit 34fe7f7

Please sign in to comment.