[llvm-dev] Got stuck with PC-rel branching

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 19 10:46:36 PST 2017


On 1/19/2017 10:21 AM, Peter Bel wrote:
> Hi,
>
> For the function call - yes, probably. But what about branching inside 
> one function (standard if-then for example)?
>
> For example:
> echo "int g() { int a = 1; if (a > 3) return 1; return 0; }" | clang 
> -x c - -o /tmp/a.o -c && objdump -d /tmp/a.o

Yes, the assembler tries to avoid emitting relocations for relative 
offsets within a section.  See MCAssembler::layout, particularly the bit 
at the end where it calls applyFixup().

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list