Skip to content

Commit

Permalink
fix building of symlite
Browse files Browse the repository at this point in the history
- add missing pure virtual functions isReadOnly
- fix isCode and isData methods to use program header permissions instead
  of just returning true
- fix printf compiler warning
- disable parseThat if using symlite as it is not compatible
- remove #include <linux/elf.h> from proccontrol/src/linux.h on aarch64
  if SYMLITE is configured as it is incompatible with <elf.h>
  • Loading branch information
kupsch committed Dec 17, 2021
1 parent 94252b8 commit aed4964
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ if(NOT ${PLATFORM} MATCHES nt)
add_subdirectory (elf)
add_subdirectory (dwarf)
add_subdirectory (symlite)
add_subdirectory (parseThat)
endif()
add_subdirectory (instructionAPI)
add_subdirectory (symtabAPI)
Expand All @@ -104,6 +103,7 @@ add_subdirectory (patchAPI)
if(${SYMREADER} MATCHES symtabAPI)
add_subdirectory (dyninstAPI)
add_subdirectory (dynC_API)
add_subdirectory (parseThat)
endif()

if(BUILD_RTLIB)
Expand Down Expand Up @@ -143,7 +143,9 @@ if(BUILD_RTLIB)
if(TARGET TBB)
add_dependencies(DyninstRT TBB)
endif()
add_dependencies(dyninstAPI DyninstRT)
if(TARGET dyninstAPI)
add_dependencies(dyninstAPI DyninstRT)
endif()
if(TARGET dyninstAPI-static)
add_dependencies(dyninstAPI-static DyninstRT)
endif()
Expand Down
2 changes: 2 additions & 0 deletions parseAPI/h/SymLiteCodeSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class SymReaderCodeRegion : public CodeRegion {
PARSER_EXPORT unsigned int getAddressWidth() const;
PARSER_EXPORT bool isCode(const Address) const;
PARSER_EXPORT bool isData(const Address) const;
PARSER_EXPORT bool isReadOnly(const Address) const;
PARSER_EXPORT Address offset() const;
PARSER_EXPORT Address length() const;
PARSER_EXPORT Architecture getArch() const;
Expand Down Expand Up @@ -109,6 +110,7 @@ class SymReaderCodeSource : public CodeSource {
PARSER_EXPORT unsigned int getAddressWidth() const;
PARSER_EXPORT bool isCode(const Address) const;
PARSER_EXPORT bool isData(const Address) const;
PARSER_EXPORT bool isReadOnly(const Address) const;
PARSER_EXPORT Address offset() const;
PARSER_EXPORT Address length() const;
PARSER_EXPORT Architecture getArch() const;
Expand Down
28 changes: 25 additions & 3 deletions parseAPI/src/SymLiteCodeSource.C
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool
SymReaderCodeRegion::isCode(const Address addr) const
{
if(!contains(addr)) return false;
return true;
return _region->perms & PF_X;

/*
// XXX this is the predicate from SymReader::isCode(a) +
Expand All @@ -163,7 +163,7 @@ bool
SymReaderCodeRegion::isData(const Address addr) const
{
if(!contains(addr)) return false;
return true;
return !(_region->perms & PF_X);


/*
Expand All @@ -174,6 +174,16 @@ SymReaderCodeRegion::isData(const Address addr) const
*/
}

bool
SymReaderCodeRegion::isReadOnly(const Address addr) const
{
if (!contains(addr)) {
return false;
}

return !(_region->perms & PF_W);
}

Address
SymReaderCodeRegion::offset() const
{
Expand Down Expand Up @@ -400,7 +410,7 @@ inline void
SymReaderCodeSource::overlapping_warn(const char * file, unsigned line) const
{
if(regionsOverlap()) {
fprintf(stderr,"Invocation of routine at %s:%d is ambiguous for "
fprintf(stderr,"Invocation of routine at %s:%u is ambiguous for "
"binaries with overlapping code regions\n",
file,line);
}
Expand Down Expand Up @@ -484,6 +494,18 @@ SymReaderCodeSource::isData(const Address addr) const
return false;
}

bool
SymReaderCodeSource::isReadOnly(const Address addr) const
{
overlapping_warn(FILE__,__LINE__);

CodeRegion * cr = lookup_region(addr);
if(cr)
return cr->isReadOnly(addr);
else
return false;
}

Address
SymReaderCodeSource::offset() const
{
Expand Down
2 changes: 2 additions & 0 deletions proccontrol/src/linux.C
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@
#include<sys/user.h>
#include<sys/procfs.h>
#include<sys/uio.h>
#if !defined(WITH_SYMLITE)
#include<linux/elf.h>
#endif
#endif

// Before glibc-2.7, sys/ptrace.h lacked PTRACE_O_* and PTRACE_EVENT_*, so we
// need them from linux/ptrace.h. (Conditionally, as later glibc conflicts.)
Expand Down

0 comments on commit aed4964

Please sign in to comment.