From 7f982b32bd276d08c5273353073cc6958aaaecac Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Sun, 4 Aug 2013 22:35:42 +0800 Subject: Add rpath support --- rld-rap.cpp | 19 +++++++++++++++++++ rld-rap.h | 5 +++++ rtems-ld.cpp | 9 ++++++++- rtems-rapper.cpp | 22 +++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/rld-rap.cpp b/rld-rap.cpp index 99bc4a3..f54f7f3 100644 --- a/rld-rap.cpp +++ b/rld-rap.cpp @@ -47,6 +47,11 @@ namespace rld */ bool add_obj_details = true; + /** + * Store the path of object files. + */ + std::string rpath; + /** * The names of the RAP sections. */ @@ -1440,6 +1445,7 @@ namespace rld section_details s_details; + if (rld::verbose () >= RLD_VERBOSE_TRACE) { std::cout << "rap:file details" << std::endl @@ -1448,6 +1454,19 @@ namespace rld comp << (uint32_t)(objs.size ()); + /* rpath for rap file */ + if (rld::verbose () >= RLD_VERBOSE_TRACE) + { + std::cout << "rap:file rpath=" << rld::rap::rpath << std::endl; + } + + comp << (uint32_t)rld::rap::rpath.length (); + + if (rld::rap::rpath.length () > 0) + { + strtable += rld::rap::rpath; + } + for (objects::iterator oi = objs.begin (); oi != objs.end (); ++oi) diff --git a/rld-rap.h b/rld-rap.h index b612e49..19969e3 100644 --- a/rld-rap.h +++ b/rld-rap.h @@ -36,6 +36,11 @@ namespace rld */ extern bool add_obj_details; + /** + * Store the path of object files. + */ + extern std::string rpath; + /** * The RAP relocation bit masks. */ diff --git a/rtems-ld.cpp b/rtems-ld.cpp index d5bc1de..34a1ee5 100644 --- a/rtems-ld.cpp +++ b/rtems-ld.cpp @@ -71,6 +71,7 @@ static struct option rld_opts[] = { { "march", required_argument, NULL, 'a' }, { "mcpu", required_argument, NULL, 'c' }, { "rap-strip", no_argument, NULL, 'S' }, + { "rpath", required_argument, NULL, 'R' }, { NULL, 0, NULL, 0 } }; @@ -112,6 +113,7 @@ usage (int exit_code) << " -a march : machine architecture (also --march)" << std::endl << " -c cpu : machine architecture's CPU (also --mcpu)" << std::endl << " -S : do not include file details (also --rap-strip)" << std::endl + << " -R : include file paths (also --rpath)" << std::endl << " -Wl,opts : link compatible flags, ignored" << std::endl << "Output Formats:" << std::endl << " rap - RTEMS application (LZ77, single image)" << std::endl @@ -190,7 +192,7 @@ main (int argc, char* argv[]) while (true) { - int opt = ::getopt_long (argc, argv, "hvwVMnb:E:o:O:L:l:a:c:e:d:u:C:W:", rld_opts, NULL); + int opt = ::getopt_long (argc, argv, "hvwVMnb:E:o:O:L:l:a:c:e:d:u:C:W:R", rld_opts, NULL); if (opt < 0) break; @@ -281,6 +283,11 @@ main (int argc, char* argv[]) rld::rap::add_obj_details = false; break; + case 'R': + rld::rap::rpath += optarg; + rld::rap::rpath += '\0'; + break; + case 'W': /* ignore linker compatiable flags */ break; diff --git a/rtems-rapper.cpp b/rtems-rapper.cpp index 91435bb..7610963 100644 --- a/rtems-rapper.cpp +++ b/rtems-rapper.cpp @@ -201,6 +201,8 @@ namespace rap uint32_t obj_num; uint8_t** obj_name; uint32_t* sec_num; + uint8_t* rpath; + uint32_t rpathlen; uint8_t* str_detail; section_details sec_details; @@ -391,6 +393,8 @@ namespace rap obj_num (0), obj_name (0), sec_num (0), + rpath (0), + rpathlen (0), str_detail (0), warnings (warnings), image (name) @@ -494,6 +498,8 @@ namespace rap { uint32_t tmp; + comp >> rpathlen; + obj_name = new uint8_t*[obj_num]; sec_num = new uint32_t[obj_num]; @@ -511,6 +517,10 @@ namespace rap if (comp.read (str_detail, tmp) != tmp) throw rld::error ("Reading file str details error", "rapper"); + if (rpathlen > 0) + rpath = (uint8_t*)str_detail; + else rpath = NULL; + section_detail sec; for (uint32_t i = 0; i < obj_num; i++) @@ -804,12 +814,22 @@ rap_show (rld::files::paths& raps, << std::setfill (' ') << std::dec << " (" << r.detail_rap_off << ')' << std::endl; + uint32_t pos = 0; + if (r.rpath != NULL) + { + std::cout << " rpath:" << std::endl; + while (pos < r.rpathlen) + { + std::cout << " " << r.rpath + pos << std::endl; + pos = std::string ((char*)(r.rpath + pos)).length () + pos + 1; + } + } + if (r.obj_num == 0) std::cout << " No details" << std::endl; else std::cout << ' ' << r.obj_num <<" Files" << std::endl; - uint32_t pos = 0; for (uint32_t i = 0; i < r.obj_num; ++i) { r.obj_name[i] = (uint8_t*) &r.str_detail[pos]; -- cgit v1.2.3