Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Print error if text_size or eh_frame_size is 0 #7

Open
wants to merge 4 commits into
base: release/5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libunwind/src/UnwindRustSgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,
size_t text_size = TEXT_SIZE;
size_t eh_base_size = EH_FRM_HDR_SIZE;

if (text_size == 0) {
write_err("%s:%d %s: Warning: text_size is 0.\n", __FILE__, __LINE__, __func__);
}

if (eh_base_size == 0) {
write_err("%s:%d %s: Warning: eh_base_size is 0.\n", __FILE__, __LINE__, __func__);
}

memset(pinfo, 0, sizeof(*pinfo));

pinfo->dlpi_addr = (ElfW(Addr))&IMAGE_BASE;
Expand Down
24 changes: 5 additions & 19 deletions libunwind/src/UnwindRustSgx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,15 @@
#include <stdint.h>

// We have to use RWLock from rust repo, it is defined in:
// src/libstd/sys/sgx/rwlock.rs.
// rwlock.rs has compile time check to ensure sizeof(RWLock) = 128.
// src/libstd/sys/sgx/unwind.rs.
// unwind.rs has compile time check to ensure sizeof(RWLock) = 16.
typedef struct {
unsigned char opaque[128];
} RWLock;
unsigned char opaque[16];
} __attribute__ ((aligned (8))) RWLock;

// The below is obtained by printing initialized bytes
// for RWLock in rust repo: src/libstd/sys/sgx/rwlock.rs.
// for RWLock in rust repo: src/libstd/sys/sgx/unwind.rs.
#define RWLOCK_INIT { \
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
}
Expand Down
2 changes: 2 additions & 0 deletions libunwind/src/UnwindRustSgxSnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
#if __GNUC__ >= 7
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif

/**************************************************************
* Original:
Expand Down