|
@@ -294,7 +294,7 @@ int dasm_link(Dst_DECL, size_t *szp)
|
|
|
|
|
|
{ /* Handle globals not defined in this translation unit. */
|
|
|
int idx;
|
|
|
- for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) {
|
|
|
+ for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
|
|
|
int n = D->lglabels[idx];
|
|
|
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
|
|
|
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
|
|
@@ -371,7 +371,10 @@ int dasm_encode(Dst_DECL, void *buffer)
|
|
|
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
|
|
|
break;
|
|
|
case DASM_REL_LG:
|
|
|
- CK(n >= 0, UNDEF_LG);
|
|
|
+ if (n < 0) {
|
|
|
+ n = (int)((ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp - 4);
|
|
|
+ goto patchrel;
|
|
|
+ }
|
|
|
/* fallthrough */
|
|
|
case DASM_REL_PC:
|
|
|
CK(n >= 0, UNDEF_PC);
|