Sure, Thanks for remind me of this. One thing I must point out, in current code logic, if "START_SEG_ADDR_RECORD" occured multiple times, only the last one works. I don't know whether GNU binutils would emit 'The Record' many times.
Best, SU Hang > -----Original Messages----- > From: "Stefan Hajnoczi" <[email protected]> > Sent Time: 2018-06-10 00:32:52 (Sunday) > To: [email protected] > Cc: "Su Hang" <[email protected]>, [email protected], > [email protected], [email protected], [email protected], "Stefan > Hajnoczi" <[email protected]> > Subject: [PATCH] loader: implement START_SEG_ADDR_RECORD > > It turns out that GNU binutils emits START_SEG_ADDR_RECORD when the start > address is within the first megabyte (< 0x100000). Therefore we must > handle this record type. > > Originally we thought this record type was x86-specific, but binutils > also emits it on non-x86 architectures. > > Based-on: <[email protected]> > Cc: Su Hang <[email protected]> > Signed-off-by: Stefan Hajnoczi <[email protected]> > --- > Su Hang: Feel free to squash this into the next revision of your hex > loader patch. Don't worry about the authorship information. > > hw/core/loader.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/hw/core/loader.c b/hw/core/loader.c > index 3c0202caa8..7843b487b2 100644 > --- a/hw/core/loader.c > +++ b/hw/core/loader.c > @@ -1423,8 +1423,14 @@ static int handle_record_type(HexParser *parser) > break; > > case START_SEG_ADDR_RECORD: > - /* TODO: START_SEG_ADDR_RECORD is x86-specific */ > - return -1; > + if (line->byte_count != 4 && line->address != 0) { > + return -1; > + } > + > + /* x86 16-bit CS:IP segmented addressing */ > + *(parser->start_addr) = (((line->data[0] << 8) | line->data[1]) << > 4) | > + (line->data[2] << 8) | line->data[3]; > + break; > > case START_LINEAR_ADDR_RECORD: > if (line->byte_count != 4 && line->address != 0) { > -- > 2.17.1
