[llvm-commits] [PATCH 3/3] Test case for readobj sections output. Part of fix for PR14723.

Sami Liedes sami.liedes at iki.fi
Fri Dec 28 10:13:41 PST 2012


On Fri, Dec 28, 2012 at 09:50:00AM -0500, Rafael EspĂ­ndola wrote:
> On 27 December 2012 18:20, Sami Liedes <sami.liedes at iki.fi> wrote:
> > I couldn't figure out what a "data section" is in LLVM parlance,
> > but now for the .text section both .isTextSection() and
> > .isDataSection() are true. I can figure out what the test in
> > ELFObjectFile is, but the comments in the parent and other relevant
> > classes seem to be silent on what the expected semantics is.
> >
> > The test in ELFObjectFile::isDataSection() is that ALLOC & WRITE is
> > set (section is allocated in memory and is writable), and the section
> > type is PROGBITS (section with initialized data or code). This is true
> > for the .text section in
> > test/Object/Inputs/shared-object-test.elf-i386.
> 
> That is a fuzzy concept for ELF. But note that the section is not
> writable. The output from readelf is:
> 
> [ 4] .text             PROGBITS        000001f0 0001f0 000013 00  AX  0   0 16

Ah, right. I misread the test. The actual code only requires that
either ALLOC or WRITE is set:

------------------------------------------------------------
template<support::endianness target_endianness, bool is64Bits>
error_code ELFObjectFile<target_endianness, is64Bits>
                        ::isSectionData(DataRefImpl Sec,
                                        bool &Result) const {
  const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
  if (sec->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE)
      && sec->sh_type == ELF::SHT_PROGBITS)
    Result = true;
  else
    Result = false;
  return object_error::success;
}

------------------------------------------------------------

> I guess the best for now is to just put a {{.*}} instead of data in the test.

Ok. I think I'll use {{(data,)?}} or something like that.

	Sami



More information about the llvm-commits mailing list