[llvm-bugs] [Bug 42539] New: ARM:out of range pc-relative fixup value

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 8 08:36:35 PDT 2019


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: unassignedclangbugs at nondot.org
          Reporter: arnd at linaro.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190708/77bdb2a5/attachment.html>


More information about the llvm-bugs mailing list