mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-24 19:00:23 +08:00
assemble: for relative addresses, convert *this segment* to fixed
We can remove OUT_ADDRESS relocations for absolute addresses (NO_SEG), but for OUT_RELADDR relocations we can remove them if they point into *our own segment*, not NO_SEG. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
90303022b4
commit
c5cbb97db4
@ -348,6 +348,7 @@ static void out(struct out_data *data)
|
|||||||
} xdata;
|
} xdata;
|
||||||
uint64_t size = data->size;
|
uint64_t size = data->size;
|
||||||
int64_t addrval;
|
int64_t addrval;
|
||||||
|
int32_t fixseg; /* Segment for which to produce fixed data */
|
||||||
|
|
||||||
if (!data->size)
|
if (!data->size)
|
||||||
return; /* Nothing to do */
|
return; /* Nothing to do */
|
||||||
@ -359,16 +360,18 @@ static void out(struct out_data *data)
|
|||||||
switch (data->type) {
|
switch (data->type) {
|
||||||
case OUT_ADDRESS:
|
case OUT_ADDRESS:
|
||||||
addrval = data->toffset;
|
addrval = data->toffset;
|
||||||
|
fixseg = NO_SEG; /* Absolute address is fixed data */
|
||||||
goto address;
|
goto address;
|
||||||
|
|
||||||
case OUT_RELADDR:
|
case OUT_RELADDR:
|
||||||
addrval = data->toffset - data->relbase;
|
addrval = data->toffset - data->relbase;
|
||||||
|
fixseg = data->segment; /* Our own segment is fixed data */
|
||||||
goto address;
|
goto address;
|
||||||
|
|
||||||
address:
|
address:
|
||||||
asize = data->size;
|
asize = data->size;
|
||||||
nasm_assert(asize <= 8);
|
nasm_assert(asize <= 8);
|
||||||
if (data->tsegment == NO_SEG && data->twrt == NO_SEG) {
|
if (data->tsegment == fixseg && data->twrt == NO_SEG) {
|
||||||
uint8_t *q = xdata.b;
|
uint8_t *q = xdata.b;
|
||||||
|
|
||||||
warn_overflow_out(addrval, asize, data->sign);
|
warn_overflow_out(addrval, asize, data->sign);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user