}
template<int size, bool big_endian>
-Sized_dwarf_line_info<size, big_endian>::Sized_dwarf_line_info(Object* object)
+Sized_dwarf_line_info<size, big_endian>::Sized_dwarf_line_info(Object* object,
+ off_t read_shndx)
: data_valid_(false), buffer_(NULL), symtab_buffer_(NULL),
directories_(), files_(), current_header_index_(-1)
{
// Now that we have successfully read all the data, parse the debug
// info.
this->data_valid_ = true;
- this->read_line_mappings();
+ this->read_line_mappings(read_shndx);
}
// Read the DWARF header.
template<int size, bool big_endian>
unsigned const char*
-Sized_dwarf_line_info<size, big_endian>::read_lines(unsigned const char* lineptr)
+Sized_dwarf_line_info<size, big_endian>::read_lines(unsigned const char* lineptr,
+ off_t shndx)
{
struct LineStateMachine lsm;
{
size_t oplength;
bool add_line = this->process_one_opcode(lineptr, &lsm, &oplength);
- if (add_line)
+ if (add_line
+ && (shndx == -1U || lsm.shndx == -1U || shndx == lsm.shndx))
{
Offset_to_lineno_entry entry
= { lsm.address, this->current_header_index_,
template<int size, bool big_endian>
void
-Sized_dwarf_line_info<size, big_endian>::read_line_mappings()
+Sized_dwarf_line_info<size, big_endian>::read_line_mappings(off_t shndx)
{
gold_assert(this->data_valid_ == true);
const unsigned char* lineptr = this->buffer_;
lineptr = this->read_header_prolog(lineptr);
lineptr = this->read_header_tables(lineptr);
- lineptr = this->read_lines(lineptr);
+ lineptr = this->read_lines(lineptr, shndx);
this->buffer_ = lineptr;
}
{
if (parameters->get_size() == 32 && !parameters->is_big_endian())
#ifdef HAVE_TARGET_32_LITTLE
- return Sized_dwarf_line_info<32, false>(object).addr2line(shndx, offset);
+ return Sized_dwarf_line_info<32, false>(object, shndx).addr2line(shndx,
+ offset);
#else
gold_unreachable();
#endif
else if (parameters->get_size() == 32 && parameters->is_big_endian())
#ifdef HAVE_TARGET_32_BIG
- return Sized_dwarf_line_info<32, true>(object).addr2line(shndx, offset);
+ return Sized_dwarf_line_info<32, true>(object, shndx).addr2line(shndx,
+ offset);
#else
gold_unreachable();
#endif
else if (parameters->get_size() == 64 && !parameters->is_big_endian())
#ifdef HAVE_TARGET_64_LITTLE
- return Sized_dwarf_line_info<64, false>(object).addr2line(shndx, offset);
+ return Sized_dwarf_line_info<64, false>(object, shndx).addr2line(shndx,
+ offset);
#else
gold_unreachable();
#endif
else if (parameters->get_size() == 64 && parameters->is_big_endian())
#ifdef HAVE_TARGET_64_BIT
- return Sized_dwarf_line_info<64, true>(object).addr2line(shndx, offset);
+ return Sized_dwarf_line_info<64, true>(object, shndx).addr2line(shndx,
+ offset);
#else
gold_unreachable();
#endif
{
public:
// Initializes a .debug_line reader for a given object file.
- Sized_dwarf_line_info(Object* object);
+ // If SHNDX is specified and non-negative, only read the debug
+ // information that pertains to the specified section.
+ Sized_dwarf_line_info(Object* object, off_t read_shndx = -1U);
private:
std::string
do_addr2line(unsigned int shndx, off_t offset);
// Start processing line info, and populates the offset_map_.
+ // If SHNDX is non-negative, only store debug information that
+ // pertains to the specified section.
void
- read_line_mappings();
+ read_line_mappings(off_t shndx);
// Reads the relocation section associated with .debug_line and
// stores relocation information in reloc_map_.
const unsigned char*
read_header_tables(const unsigned char* lineptr);
- // Reads the DWARF2/3 line information.
+ // Reads the DWARF2/3 line information. If shndx is non-negative,
+ // discard all line information that doesn't pertain to the given
+ // section.
const unsigned char*
- read_lines(const unsigned char* lineptr);
+ read_lines(const unsigned char* lineptr, off_t shndx);
// Process a single line info opcode at START using the state
// machine at LSM. Return true if we should define a line using the