26package org.jau.sys.elf;
28import static org.jau.sys.elf.IOUtils.getString;
29import static org.jau.sys.elf.IOUtils.long2Int;
30import static org.jau.sys.elf.IOUtils.readBytes;
31import static org.jau.sys.elf.IOUtils.seek;
32import static org.jau.sys.elf.IOUtils.toHexString;
34import java.io.IOException;
35import java.io.RandomAccessFile;
36import java.nio.ByteBuffer;
168 public static final short SHN_ABS = (short)0xfff1;
184 private final int idx;
188 this( eh, ByteBuffer.wrap(buf, 0, buf.length), sectionIdx );
206 void initName(
final Section strS,
final int nameOffset)
throws IndexOutOfBoundsException {
207 name = getString(strS.data, strS.offset + nameOffset, strS.length - nameOffset,
null);
244 if( 0 == s_size || 0 > s_size ) {
245 throw new IllegalArgumentException(
"Shdr["+idx+
"] has invalid int size: "+
raw.
getSh_size()+
" -> "+s_size);
247 final byte[] s_buf =
new byte[s_size];
248 return readSectionImpl(in, s_buf, 0, s_size);
262 public Section readSection(
final RandomAccessFile in,
final byte[] b,
final int b_off,
final int r_len)
throws IOException, IllegalArgumentException {
264 if( 0 == s_size || 0 > s_size ) {
265 throw new IllegalArgumentException(
"Shdr["+idx+
"] has invalid int size: "+
raw.
getSh_size()+
" -> "+s_size);
267 if( r_len > s_size ) {
268 throw new IllegalArgumentException(
"Shdr["+idx+
"] has only "+s_size+
" bytes, while read request is of "+r_len+
" bytes");
270 return readSectionImpl(in, b, b_off, r_len);
273 Section readSectionImpl(
final RandomAccessFile in,
final byte[] b,
final int b_off,
final int r_len)
throws IOException, IllegalArgumentException {
276 readBytes(in, b, b_off, r_len);
280 return new Section(
this, b, b_off, r_len);
ARM EABI attributes within section header SectionHeader#SHT_ARM_ATTRIBUTES.
long getSh_flags()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
int getSh_info()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
int getSh_link()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
static Shdr create(final int mdIdx)
long getSh_size()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
int getSh_type()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
long getSh_offset()
Getter for native field: CType['ElfN_Off' (typedef), size [fixed false, lnx64 8], [int]].