[llvm] r196440 - [mc] Fix ELF st_other flag.
NAKAMURA Takumi
geek4civic at gmail.com
Wed Dec 4 18:28:46 PST 2013
I moved a test into MC/ELF in r196457.
Feel free to move again if we needed new directories like tests/MC/ELF/ARM.
2013/12/5 Logan Chien <tzuhsiang.chien at gmail.com>:
> Author: logan
> Date: Wed Dec 4 18:34:11 2013
> New Revision: 196440
>
> URL: http://llvm.org/viewvc/llvm-project?rev=196440&view=rev
> Log:
> [mc] Fix ELF st_other flag.
>
> ELF_Other_Weakref and ELF_Other_ThumbFunc seems to be LLVM
> internal ELF symbol flags. These should not be emitted to
> object file.
>
> This commit defines ELF_STO_Shift for the target-defined
> flags for st_other, and increase the value of
> ELF_Other_Shift to 16.
>
> Added:
> llvm/trunk/test/MC/ELF/thumb-st_other.s
> Modified:
> llvm/trunk/include/llvm/MC/MCELFSymbolFlags.h
> llvm/trunk/lib/MC/ELFObjectWriter.cpp
> llvm/trunk/lib/MC/MCELF.cpp
>
> Modified: llvm/trunk/include/llvm/MC/MCELFSymbolFlags.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFSymbolFlags.h?rev=196440&r1=196439&r2=196440&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCELFSymbolFlags.h (original)
> +++ llvm/trunk/include/llvm/MC/MCELFSymbolFlags.h Wed Dec 4 18:34:11 2013
> @@ -21,10 +21,12 @@
>
> namespace llvm {
> enum {
> - ELF_STT_Shift = 0, // Shift value for STT_* flags.
> - ELF_STB_Shift = 4, // Shift value for STB_* flags.
> - ELF_STV_Shift = 8, // Shift value for STV_* flags.
> - ELF_Other_Shift = 10 // Shift value for other flags.
> + ELF_STT_Shift = 0, // Shift value for STT_* flags.
> + ELF_STB_Shift = 4, // Shift value for STB_* flags.
> + ELF_STV_Shift = 8, // Shift value for STV_* flags.
> + ELF_STO_Shift = 10, // Shift value for STO_* flags.
> + ELF_Other_Shift = 16 // Shift value for llvm local flags,
> + // not part of the final object file
> };
>
> enum ELFSymbolFlags {
>
> Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=196440&r1=196439&r2=196440&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
> +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Dec 4 18:34:11 2013
> @@ -551,8 +551,7 @@ void ELFObjectWriter::WriteSymbol(MCData
> // Other and Visibility share the same byte with Visibility using the lower
> // 2 bits
> uint8_t Visibility = MCELF::GetVisibility(OrigData);
> - uint8_t Other = MCELF::getOther(OrigData) <<
> - (ELF_Other_Shift - ELF_STV_Shift);
> + uint8_t Other = MCELF::getOther(OrigData) << (ELF_STO_Shift - ELF_STV_Shift);
> Other |= Visibility;
>
> uint64_t Value = SymbolValue(Data, Layout);
>
> Modified: llvm/trunk/lib/MC/MCELF.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELF.cpp?rev=196440&r1=196439&r2=196440&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCELF.cpp (original)
> +++ llvm/trunk/lib/MC/MCELF.cpp Wed Dec 4 18:34:11 2013
> @@ -72,13 +72,13 @@ unsigned MCELF::GetVisibility(MCSymbolDa
> // Other is stored in the last six bits of st_other
> // st_other values are stored in the second byte of get/setFlags
> void MCELF::setOther(MCSymbolData &SD, unsigned Other) {
> - uint32_t OtherFlags = SD.getFlags() & ~(0x3f << ELF_Other_Shift);
> - SD.setFlags(OtherFlags | (Other << ELF_Other_Shift));
> + uint32_t OtherFlags = SD.getFlags() & ~(0x3f << ELF_STO_Shift);
> + SD.setFlags(OtherFlags | (Other << ELF_STO_Shift));
> }
>
> unsigned MCELF::getOther(MCSymbolData &SD) {
> unsigned Other =
> - (SD.getFlags() & (0x3f << ELF_Other_Shift)) >> ELF_Other_Shift;
> + (SD.getFlags() & (0x3f << ELF_STO_Shift)) >> ELF_STO_Shift;
> return Other;
> }
>
>
> Added: llvm/trunk/test/MC/ELF/thumb-st_other.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/thumb-st_other.s?rev=196440&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/ELF/thumb-st_other.s (added)
> +++ llvm/trunk/test/MC/ELF/thumb-st_other.s Wed Dec 4 18:34:11 2013
> @@ -0,0 +1,19 @@
> +@ Check the value of st_other for thumb function.
> +
> +@ ARM does not define any st_other flags for thumb function. The value
> +@ for st_other should always be 0.
> +
> +@ RUN: llvm-mc < %s -triple thumbv5-linux-gnueabi -filetype=obj -o - \
> +@ RUN: | llvm-readobj -t | FileCheck %s
> +
> + .syntax unified
> + .text
> + .align 2
> + .thumb_func
> + .global main
> + .type main,%function
> +main:
> + bx lr
> +
> +@ CHECK: Name: main
> +@ CHECK: Other: 0
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list