mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-16 19:32:07 +00:00
add a way to manually specify what goes in which segment
This commit is contained in:
parent
207b094372
commit
28779ec31e
@ -100,6 +100,8 @@ int main(int argc, char *argv[])
|
||||
bool segments = true;
|
||||
bool stripMacsbug = false;
|
||||
|
||||
SegmentMap segmentMap;
|
||||
|
||||
vector<string> args2;
|
||||
for(auto p = args.begin(), e = args.end(); p != e; ++p)
|
||||
{
|
||||
@ -138,7 +140,7 @@ int main(int argc, char *argv[])
|
||||
++p;
|
||||
if(p == e)
|
||||
errx(EXIT_FAILURE, "--mac-segments missing argument");
|
||||
//segmentMapFile = *p;
|
||||
segmentMap = SegmentMap(*p);
|
||||
}
|
||||
else if(*p == "--mac-strip-macsbug")
|
||||
{
|
||||
@ -157,12 +159,12 @@ int main(int argc, char *argv[])
|
||||
if(fd < 0)
|
||||
errx(EXIT_FAILURE, "can't create temp file");
|
||||
|
||||
SegmentMap segmentMap;
|
||||
{
|
||||
ofstream out(tmpfile);
|
||||
if(segments)
|
||||
{
|
||||
segmentMap.CreateLdScript(out, stripMacsbug);
|
||||
segmentMap.CreateLdScript(std::cout, stripMacsbug);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -18,6 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "SegmentMap.h"
|
||||
#include <fstream>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
SegmentInfo::SegmentInfo()
|
||||
{
|
||||
@ -53,6 +57,62 @@ SegmentMap::SegmentMap()
|
||||
"*");
|
||||
}
|
||||
|
||||
SegmentMap::SegmentMap(std::string filename)
|
||||
{
|
||||
segments.emplace_back(1, "Runtime",
|
||||
"*/libretrocrt.a:start.c.obj",
|
||||
"*/libretrocrt.a:relocate.c.obj",
|
||||
"*/libretrocrt.a:MultiSegApp.c.obj",
|
||||
"*/libretrocrt.a:LoadSeg.s.obj",
|
||||
"*/libretrocrt.a:*",
|
||||
"*/libgcc.a:*",
|
||||
"*/libc.a:*"
|
||||
);
|
||||
|
||||
std::ifstream in(filename);
|
||||
int id = -1;
|
||||
int nextID = 3;
|
||||
while(in)
|
||||
{
|
||||
std::string s;
|
||||
in >> std::ws;
|
||||
std::getline(in, s);
|
||||
std::cout << "segs: " << s << std::endl;
|
||||
if(!in)
|
||||
break;
|
||||
|
||||
std::string upper;
|
||||
std::transform(s.begin(), s.end(), std::back_inserter(upper), [](char c) { return std::toupper(c); });
|
||||
|
||||
if(s[0] == '#')
|
||||
continue;
|
||||
else if(upper == "SEGMENT" || (upper.substr(0,7) == "SEGMENT" && std::isspace(upper[7])))
|
||||
{
|
||||
std::string name;
|
||||
|
||||
auto p = s.begin() + 7;
|
||||
while(p != s.end() && std::isspace(*p))
|
||||
++p;
|
||||
name = std::string(p, s.end());
|
||||
id = nextID++;
|
||||
|
||||
segments.emplace_back(id, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(id < 0)
|
||||
{
|
||||
throw std::runtime_error("missing SEGMENT directive.\n");
|
||||
}
|
||||
|
||||
segments.back().filters.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
segments.emplace_back(2, "Main",
|
||||
"*");
|
||||
}
|
||||
|
||||
std::string SegmentMap::GetSegmentName(int id)
|
||||
{
|
||||
for(auto& seg : segments)
|
||||
|
@ -47,6 +47,7 @@ class SegmentMap
|
||||
std::vector<SegmentInfo> segments;
|
||||
public:
|
||||
SegmentMap();
|
||||
SegmentMap(std::string filename);
|
||||
|
||||
void CreateLdScript(std::ostream& out, bool stripMacsbug);
|
||||
std::string GetSegmentName(int id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user