From a2b1d16bd059010bb92e9164e693cb97c61dcc01 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 18 Jul 2013 11:05:02 +0800 Subject: Add support for relocations which reference local symbols Signed-off-by: Peng Fan --- rld-files.cpp | 3 ++- rld-files.h | 1 + rld-rap.cpp | 21 ++++++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/rld-files.cpp b/rld-files.cpp index 9887e48..45a10bd 100644 --- a/rld-files.cpp +++ b/rld-files.cpp @@ -910,7 +910,8 @@ namespace rld symname (er.symbol ().name ()), symtype (er.symbol ().type ()), symsect (er.symbol ().section_index ()), - symvalue (er.symbol ().value ()) + symvalue (er.symbol ().value ()), + symbinding (er.symbol ().binding ()) { } diff --git a/rld-files.h b/rld-files.h index 31ea764..019357e 100644 --- a/rld-files.h +++ b/rld-files.h @@ -625,6 +625,7 @@ namespace rld const uint32_t symtype; //< The type of symbol. const int symsect; //< The symbol's section symbol. const uint32_t symvalue; //< The symbol's value. + const uint32_t symbinding;//< The symbol's binding. /** * Construct from an ELF relocation record. diff --git a/rld-rap.cpp b/rld-rap.cpp index ab57b3e..2b805cf 100644 --- a/rld-rap.cpp +++ b/rld-rap.cpp @@ -59,13 +59,14 @@ namespace rld */ struct relocation { - uint32_t offset; //< The offset in the section to apply the fixup. - uint32_t info; //< The ELF info record. - uint32_t addend; //< The ELF constant addend. - std::string symname; //< The symbol name if there is one. - uint32_t symtype; //< The type of symbol. - int symsect; //< The symbol's RAP section. - uint32_t symvalue; //< The symbol's default value. + uint32_t offset; //< The offset in the section to apply the fixup. + uint32_t info; //< The ELF info record. + uint32_t addend; //< The ELF constant addend. + std::string symname; //< The symbol name if there is one. + uint32_t symtype; //< The type of symbol. + int symsect; //< The symbol's RAP section. + uint32_t symvalue; //< The symbol's default value. + uint32_t symbinding;//< The symbol's binding. /** * Construct the relocation using the file relocation, the offset of the @@ -430,7 +431,8 @@ namespace rld symname (reloc.symname), symtype (reloc.symtype), symsect (reloc.symsect), - symvalue (reloc.symvalue) + symvalue (reloc.symvalue), + symbinding (reloc.symbinding) { } @@ -673,6 +675,7 @@ namespace rld << " reloc.addend=" << freloc.addend << " reloc.symtype=" << freloc.symtype << " reloc.symsect=" << freloc.symsect + << " reloc.symbinding=" << freloc.symbinding << std::endl; sec.relocs.push_back (relocation (freloc, offset)); @@ -1268,7 +1271,7 @@ namespace rld offset = sec.offset + reloc.offset; - if (reloc.symtype == STT_SECTION) + if ((reloc.symtype == STT_SECTION) || (reloc.symbinding == STB_LOCAL)) { int rap_symsect = obj.find (reloc.symsect); -- cgit v1.2.3