# for creating them.
#
# This needs further abstraction for dealing with non-GNU linkers.
+comma := ,
$(1):
$(if $(quiet),@echo " [LD] $$@")
$(qexec)$$(LD) -shared $$(LDFLAGS) \
- -Wl,--no-undefined -Wl,-soname,$$(SONAME) \
- -Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \
+ -Wl,--no-undefined \
+ $$(if $$(SONAME), -Wl$$(comma)-soname$$(comma)$$(SONAME)) \
+ $$(if $$(SO_VERSION_SCRIPT), -Wl$$(comma)--version-script$$(comma)$$(SO_VERSION_SCRIPT)) \
+ -o $$@ \
$$(filter %.o,$$?) $$(extralibs)
endef
.libs: $(LIBS)
@touch $@
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
-$(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
+$(foreach lib,$(filter %.so %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist)
return 1;
}
+int parse_elf_program(elf_obj_t *elf, int idx, Elf32_Phdr *phdr32, Elf64_Phdr *phdr64)
+{
+ if (phdr32)
+ {
+ if (idx >= elf->hdr32.e_phnum)
+ goto bail;
+
+ COPY_STRUCT(phdr32, elf->buf, elf->hdr32.e_phoff + idx * elf->hdr32.e_phentsize,
+ elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_type);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_offset);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_vaddr);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_paddr);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_filesz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_memsz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_flags);
+ ENDIAN_ASSIGN_IN_PLACE(phdr32->p_align);
+ }
+ else /* if (phdr64) */
+ {
+ if (idx >= elf->hdr64.e_phnum)
+ goto bail;
+
+ COPY_STRUCT(phdr64, elf->buf, elf->hdr64.e_phoff + idx * elf->hdr64.e_phentsize,
+ elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_type);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_offset);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_vaddr);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_paddr);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_filesz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_memsz);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_flags);
+ ENDIAN_ASSIGN_IN_PLACE(phdr64->p_align);
+ }
+
+ return 0;
+bail:
+ return 1;
+}
+
char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx)
{
if (elf->bits == 32)
int i;
Elf32_Off strtab_off32;
Elf64_Off strtab_off64; /* save String Table offset for later use */
+ Elf32_Word load_alignment32;
+ Elf64_Xword load_alignment64;
memset(&elf, 0, sizeof(elf));
elf.buf = buf;
elf.sz = sz;
- /* Parse Header */
if (parse_elf_header(&elf))
goto bail;
+ /* Parse Section and Program headers for string table offset and data
+ * aligment, respectively.
+ */
if (elf.bits == 32)
{
Elf32_Shdr shdr;
}
}
}
+ Elf32_Phdr phdr;
+ for (i = 0; i< elf.hdr32.e_phnum; i++)
+ {
+ parse_elf_program(&elf, i, &phdr, NULL);
+ if (phdr.p_type == PT_LOAD)
+ {
+ load_alignment32 = phdr.p_align;
+ }
+ }
}
else /* if (elf.bits == 64) */
{
}
}
}
+ Elf64_Phdr phdr;
+ for (i = 0; i< elf.hdr64.e_phnum; i++)
+ {
+ parse_elf_program(&elf, i, NULL, &phdr);
+ if (phdr.p_type == PT_LOAD)
+ {
+ load_alignment64 = phdr.p_align;
+ }
+ }
}
/* Parse all Symbol Tables */
{
parse_elf_section(&elf, i, &shdr, NULL);
- if (shdr.sh_type == SHT_SYMTAB)
+ if (shdr.sh_type == SHT_DYNSYM)
{
for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size;
}
memcpy(&val,
- elf.buf + dhdr.sh_offset + sym.st_value,
+ elf.buf + (sym.st_value - load_alignment32),
sym.st_size);
}
{
parse_elf_section(&elf, i, NULL, &shdr);
- if (shdr.sh_type == SHT_SYMTAB)
+ if (shdr.sh_type == SHT_DYNSYM)
{
for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size;
}
memcpy(&val,
- elf.buf + dhdr.sh_offset + sym.st_value,
+ elf.buf + (sym.st_value - load_alignment64),
sym.st_size);
}
#
# Calculate platform- and compiler-specific offsets for hand coded assembly
#
+
+#
+# Parse shared object files for elf, object files for mach-o and coff
+#
+ifeq ($(TGT_OS), linux)
+OIE_LIB:=yes
+OIE_EXT:=.so
+else
+OIE_EXT:=.o
+endif
+
ifeq ($(CONFIG_EXTERNAL_BUILD),) # Visual Studio uses obj_int_extract.bat
ifeq ($(ARCH_ARM), yes)
asm_com_offsets.asm: obj_int_extract
- asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o
+ asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c$(OIE_EXT)
./obj_int_extract rvds $< $(ADS2GAS) > $@
OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o
+ ifeq ($(OIE_LIB), yes)
+ $(VP8_PREFIX)common/asm_com_offsets.c.so: $(VP8_PREFIX)common/asm_com_offsets.c.o
+ LIBS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.so
+ endif
CLEAN-OBJS += asm_com_offsets.asm
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm
endif
ifeq ($(ARCH_ARM)$(ARCH_X86)$(ARCH_X86_64), yes)
ifeq ($(CONFIG_VP8_ENCODER), yes)
asm_enc_offsets.asm: obj_int_extract
- asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
+ asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c$(OIE_EXT)
./obj_int_extract rvds $< $(ADS2GAS) > $@
OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
+ ifeq ($(OIE_LIB), yes)
+ $(VP8_PREFIX)encoder/asm_enc_offsets.c.so: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
+ LIBS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.so
+ endif
CLEAN-OBJS += asm_enc_offsets.asm
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm
endif
ifeq ($(ARCH_ARM), yes)
ifeq ($(CONFIG_VP8_DECODER), yes)
asm_dec_offsets.asm: obj_int_extract
- asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
+ asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c$(OIE_EXT)
./obj_int_extract rvds $< $(ADS2GAS) > $@
OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
+ ifeq ($(OIE_LIB), yes)
+ $(VP8_PREFIX)decoder/asm_dec_offsets.c.so: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
+ LIBS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.so
+ endif
CLEAN-OBJS += asm_dec_offsets.asm
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm
endif