i386-asm: fix pc-relative label ariths

See test. We need to use 'ind' from later when the address
field of the instruction is put.

Also: fix crash when the substracted symbol is undefined
Also: assume asm-symbols to be lvalues (except func/array)
This commit is contained in:
grischka
2024-03-02 12:48:44 +01:00
parent 9675c1e245
commit ca061f3a96
4 changed files with 17 additions and 2 deletions

View File

@@ -3758,6 +3758,16 @@ void asm_dot_test(void)
#endif
}
void asm_pcrel_test(void)
{
unsigned o1, o2;
/* subtract text-section label from forward or other-section label */
asm("1: mov $2f-1b,%%eax; mov %%eax,%0" : "=m"(o1));
/* verify ... */
asm("2: mov $2b,%%eax; sub $1b,%%eax; mov %%eax,%0" : "=m"(o2));
printf("%s : %x\n", __FUNCTION__, o1 - o2); /* should be zero */
}
void asm_test(void)
{
char buf[128];
@@ -3849,6 +3859,7 @@ void asm_test(void)
test_asm_dead_code();
test_asm_call();
asm_dot_test();
asm_pcrel_test();
return;
label1:
goto label2;