https://bugs.llvm.org/show_bug.cgi?id=42539

            Bug ID: 42539
           Summary: ARM:out of range pc-relative fixup value
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

A file in the linux kernel got compiled into an invalid assembler output. I
reduced this to:

$ clang-9 -std=gnu89 --target=arm-linux-gnueabi -fsanitize=kernel-address -O2 
-Wall -Wno-unused-value -Wno-parentheses-equality 
-Wno-unused-command-line-argument -Wno-ignored-optimization-argument
/tmp/z-4fd29d.s:33: Error: bad immediate value for offset (4104)

typedef struct { long x[4 * 8 / 2]; } map_word;
struct {
  void (*write)();
} g;
struct flchip {
  long start;
  int state;
} __attribute__((__packed__));
int a, b, c;
int fn2(void);
struct flchip d, h;
map_word e, f;
void fn1() {
  g.write(e, h.start);
  g.write(g, f, h.start);
  while (({
    for (; b;)
      ;
    c;
  }))
    a = fn2();
  asm(".rep 6; nop; .endr");
  while (d.state)
    ;
}

See also https://godbolt.org/z/DSM2Jy

It seems that clang when clang tries to guess the size of the instructions in
an inline assembly, it gets the '.rep' statement wrong and assumes a smaller
number. Replacing ".rep 6; nop; .endr" with six straight nop instructions
avoids the problem.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to