mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-14 15:39:45 +00:00
8183149: [AOT] SEGV in AMD64MathStub.pow: alignment for ArrayDataPointerConstant is not honored
Reviewed-by: kvn
This commit is contained in:
parent
1a92a2ad53
commit
0fb3cfd067
@ -53,9 +53,8 @@ public class ElfSection {
|
||||
private static int shStrTabNrOfBytes = 0;
|
||||
|
||||
public ElfSection(String sectName, byte [] sectData, int sectFlags,
|
||||
int sectType, boolean hasRelocations, int sectIndex) {
|
||||
|
||||
long align;
|
||||
int sectType, boolean hasRelocations, int align,
|
||||
int sectIndex) {
|
||||
|
||||
section = ElfByteBuffer.allocate(Elf64_Shdr.totalsize);
|
||||
|
||||
@ -90,35 +89,19 @@ public class ElfSection {
|
||||
|
||||
section.putLong(Elf64_Shdr.sh_entsize.off, 0);
|
||||
|
||||
// Determine the alignment and entrysize
|
||||
// Determine the entrysize
|
||||
// based on type of section
|
||||
switch (sectType) {
|
||||
case Elf64_Shdr.SHT_PROGBITS:
|
||||
if ((sectFlags & Elf64_Shdr.SHF_EXECINSTR) != 0)
|
||||
align = 16;
|
||||
else
|
||||
align = 4;
|
||||
break;
|
||||
case Elf64_Shdr.SHT_SYMTAB:
|
||||
align = 8;
|
||||
section.putLong(Elf64_Shdr.sh_entsize.off, Elf64_Sym.totalsize);
|
||||
break;
|
||||
case Elf64_Shdr.SHT_STRTAB:
|
||||
align = 1;
|
||||
break;
|
||||
case Elf64_Shdr.SHT_RELA:
|
||||
align = 8;
|
||||
section.putLong(Elf64_Shdr.sh_entsize.off, Elf64_Rela.totalsize);
|
||||
break;
|
||||
case Elf64_Shdr.SHT_REL:
|
||||
align = 8;
|
||||
section.putLong(Elf64_Shdr.sh_entsize.off, Elf64_Rel.totalsize);
|
||||
break;
|
||||
case Elf64_Shdr.SHT_NOBITS:
|
||||
align = 4;
|
||||
break;
|
||||
default:
|
||||
align = 8;
|
||||
break;
|
||||
}
|
||||
section.putLong(Elf64_Shdr.sh_addralign.off, align);
|
||||
|
||||
@ -69,6 +69,7 @@ public class JELFRelocObject {
|
||||
String sectName,
|
||||
byte [] scnData,
|
||||
boolean hasRelocs,
|
||||
int align,
|
||||
int scnFlags,
|
||||
int scnType) {
|
||||
|
||||
@ -77,6 +78,7 @@ public class JELFRelocObject {
|
||||
scnFlags,
|
||||
scnType,
|
||||
hasRelocs,
|
||||
align,
|
||||
sections.size());
|
||||
// Add this section to our list
|
||||
sections.add(sect);
|
||||
@ -91,7 +93,7 @@ public class JELFRelocObject {
|
||||
byte[] scnData = c.getByteArray();
|
||||
|
||||
int scnType = Elf64_Shdr.SHT_PROGBITS;
|
||||
boolean zeros = hasRelocs;
|
||||
boolean zeros = !hasRelocs;
|
||||
if (zeros) {
|
||||
for (byte b : scnData) {
|
||||
if (b != 0) {
|
||||
@ -105,7 +107,7 @@ public class JELFRelocObject {
|
||||
}
|
||||
|
||||
sect = createByteSection(sections, c.getContainerName(),
|
||||
scnData, hasRelocs,
|
||||
scnData, hasRelocs, segmentSize,
|
||||
scnFlags, scnType);
|
||||
c.setSectionId(sect.getSectionId());
|
||||
}
|
||||
@ -136,7 +138,7 @@ public class JELFRelocObject {
|
||||
ArrayList<ElfSection> sections = new ArrayList<ElfSection>();
|
||||
|
||||
// Create the null section
|
||||
createByteSection(sections, null, null, false, 0, 0);
|
||||
createByteSection(sections, null, null, false, 1, 0, 0);
|
||||
|
||||
// Create text section
|
||||
createCodeSection(sections, binContainer.getCodeContainer());
|
||||
@ -170,6 +172,7 @@ public class JELFRelocObject {
|
||||
".strtab",
|
||||
symtab.getStrtabArray(),
|
||||
false,
|
||||
1,
|
||||
0,
|
||||
Elf64_Shdr.SHT_STRTAB);
|
||||
|
||||
@ -181,6 +184,7 @@ public class JELFRelocObject {
|
||||
".symtab",
|
||||
symtab.getSymtabArray(),
|
||||
false,
|
||||
8,
|
||||
0,
|
||||
Elf64_Shdr.SHT_SYMTAB);
|
||||
symTabSection.setLink(strTabSection.getSectionId());
|
||||
@ -196,6 +200,7 @@ public class JELFRelocObject {
|
||||
".shstrtab",
|
||||
null,
|
||||
false,
|
||||
1,
|
||||
0,
|
||||
Elf64_Shdr.SHT_STRTAB);
|
||||
eh.setSectionStrNdx(shStrTabSection.getSectionId());
|
||||
@ -435,13 +440,14 @@ public class JELFRelocObject {
|
||||
ElfSection sect = sections.get(i);
|
||||
String relname = ".rela" + sect.getName();
|
||||
ElfSection relocSection = createByteSection(sections,
|
||||
relname,
|
||||
elfRelocTable.getRelocData(i),
|
||||
false,
|
||||
0,
|
||||
Elf64_Shdr.SHT_RELA);
|
||||
relocSection.setLink(symtabsectidx);
|
||||
relocSection.setInfo(sect.getSectionId());
|
||||
relname,
|
||||
elfRelocTable.getRelocData(i),
|
||||
false,
|
||||
8,
|
||||
0,
|
||||
Elf64_Shdr.SHT_RELA);
|
||||
relocSection.setLink(symtabsectidx);
|
||||
relocSection.setInfo(sect.getSectionId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,8 @@ public class JMachORelocObject {
|
||||
segName,
|
||||
c.getByteArray(),
|
||||
scnFlags,
|
||||
c.hasRelocations());
|
||||
c.hasRelocations(),
|
||||
segmentSize);
|
||||
// Add this section to our list
|
||||
sections.add(sect);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public class MachOSection {
|
||||
byte [] data;
|
||||
boolean hasrelocations;
|
||||
|
||||
public MachOSection(String sectName, String segName, byte [] sectData, int sectFlags, boolean hasRelocations) {
|
||||
public MachOSection(String sectName, String segName, byte [] sectData, int sectFlags, boolean hasRelocations, int align) {
|
||||
section = MachOByteBuffer.allocate(section_64.totalsize);
|
||||
|
||||
// TODO: Hotspot uses long section names.
|
||||
@ -57,8 +57,8 @@ public class MachOSection {
|
||||
|
||||
section.putLong(section_64.size.off, sectData.length);
|
||||
|
||||
// For now use 8 byte alignment
|
||||
section.putInt(section_64.align.off, 3);
|
||||
section.putInt(section_64.align.off,
|
||||
31 - Integer.numberOfLeadingZeros(align));
|
||||
|
||||
section.putInt(section_64.flags.off, sectFlags);
|
||||
|
||||
|
||||
@ -62,6 +62,9 @@ public class JPECoffRelocObject {
|
||||
this.binContainer = binContainer;
|
||||
this.pecoffContainer = new PECoffContainer(outputFileName, aotVersion);
|
||||
this.segmentSize = binContainer.getCodeSegmentSize();
|
||||
if (segmentSize != 64) {
|
||||
System.out.println("binContainer alignment size not 64 bytes, update JPECoffRelocObject");
|
||||
}
|
||||
}
|
||||
|
||||
private PECoffSection createByteSection(ArrayList<PECoffSection>sections,
|
||||
@ -97,20 +100,20 @@ public class JPECoffRelocObject {
|
||||
private void createCodeSection(ArrayList<PECoffSection>sections, CodeContainer c) {
|
||||
createByteSection(sections, c, IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_READ |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_EXECUTE |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_16BYTES |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_64BYTES |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_CNT_CODE);
|
||||
}
|
||||
|
||||
private void createReadOnlySection(ArrayList<PECoffSection>sections, ReadOnlyDataContainer c) {
|
||||
createByteSection(sections, c, IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_READ |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_16BYTES |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_64BYTES |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_CNT_INITIALIZED_DATA);
|
||||
}
|
||||
|
||||
private void createReadWriteSection(ArrayList<PECoffSection>sections, ByteContainer c) {
|
||||
int scnFlags = IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_READ |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_WRITE |
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_8BYTES;
|
||||
IMAGE_SECTION_HEADER.IMAGE_SCN_ALIGN_64BYTES;
|
||||
|
||||
if (c.getByteArray().length > 0)
|
||||
scnFlags |= IMAGE_SECTION_HEADER.IMAGE_SCN_CNT_INITIALIZED_DATA;
|
||||
|
||||
@ -111,6 +111,8 @@ public class PECoff {
|
||||
public static final int IMAGE_SCN_ALIGN_4BYTES = 0x300000;
|
||||
public static final int IMAGE_SCN_ALIGN_8BYTES = 0x400000;
|
||||
public static final int IMAGE_SCN_ALIGN_16BYTES = 0x500000;
|
||||
public static final int IMAGE_SCN_ALIGN_32BYTES = 0x600000;
|
||||
public static final int IMAGE_SCN_ALIGN_64BYTES = 0x700000;
|
||||
public static final int IMAGE_SCN_ALIGN_MASK = 0xf00000;
|
||||
public static final int IMAGE_SCN_ALIGN_SHIFT = 20;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user