@Carl: OK here are the changes I've made:<br><br>file: src/boot/elfboot.c<br><br>+ #include <openssl/sha.h><br>+ #include <openssl/evp.h><br><br>+ #define SHA256_DIGEST_LENGTH    32<br><br>+ static void measure_elf(unsigned char *header, size_t length) {<br>
        unsigned char md[SHA256_DIGEST_LENGTH];<br><br>        EVP_Digest(header,length,md,NULL,EVP_sha256(),NULL);<br><br>         //write_log_entry_in_tcpa(hash); // Write hash to the acpi table<br><br>         measure_and_extend(md); //Write hash to the tpm<br>
         return 1;<br>}<br><br>/*<br> * Dummy function for tpm capability<br> */<br>+ static int measure_and_extend(unsigned char hash) {<br>        return 1;<br>}<br><br><br>static int load_elf_segments(<br>        struct segment *head, unsigned char *header, unsigned long header_size)<br>
{<br><br>                        memcpy(dest, &header[start_offset], len);<br>                     + measure_elf(&header[start_offset], len); //Pass the elf code to the measurement function<br><br>}<br><br><br>file target/emulation/qemu-x86/qemu-x86/normal/Makfile:<br>
<br>src/boot/elfboot.o: $(TOP)//src/boot/elfboot.c<br>        gcc -m32 -c  -fno-stack-protector -I/home/sphinx/coreboot/coreboot_o/coreboot-v2/src/include -I/home/sphinx/coreboot/coreboot_o/coreboot-v2/src/arch/i386/include -I/usr/lib/gcc/i486-linux-gnu/4.3.2/include -include /home/sphinx/coreboot/coreboot_o/coreboot-v2/targets/emulation/qemu-x86/qemu-x86/normal/settings.h -O2 -g -nostdlib -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wstrict-aliasing -Wshadow -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer -I /usr/local/ssl/include -lcrypto -lssl -Wall -o src/boot/elfboot.o /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a /home/sphinx/coreboot/coreboot_o/coreboot-v2//src/boot/elfboot.c<br>
<br>all: coreboot.rom<br>coreboot_ram.o: src/arch/$(ARCH)/lib/c_start.o $(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)<br>        $(CC) $(DISTRO_LFLAGS) -nostdlib -I /usr/local/ssl/include -lcrypto -lssl -r -o $@ /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a $^<br>
coreboot_ram: coreboot_ram.o $(TOP)/src/config/coreboot_ram.ld ldoptions<br>        gcc -m32 -Wl,--build-id=none -nostdlib -nostartfiles -I /usr/local/ssl/include -lcrypto -lssl -static -o coreboot_ram -T /home/sphinx/coreboot/coreboot_o/coreboot-v2/src/config/coreboot_ram.ld /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a coreboot_ram.o<br>
<br><br>As I've said in IRC don't wonder, cause of the direct gcc calls, I just need to get it running and tried out a lot of stuff.<br><br>Regards,<br><br>René<br><br><br><div class="gmail_quote">2009/7/28 René Reuter <span dir="ltr"><<a href="mailto:reuter.rene@googlemail.com">reuter.rene@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Ok first two commands I get the same output like you.<br><br>The third:<div class="im"><br><br>
gcc -m32 -Wl,--build-id=none -nostdlib -nostartfiles -L/usr/lib/<br>
-lcrypto -lssl -static -print-file-name=libcrypto.a<br><br></div>/usr/bin/ld: no input files<div class="im"><br>collect2: ld returned 1 exit status<br><br><br></div>The objdump returns elf32-i386 for all<br><br><br>René<br>
<br><br><div class="gmail_quote"><div class="im">
2009/7/28 Carl-Daniel Hailfinger <span dir="ltr"><<a href="mailto:c-d.hailfinger.devel.2006@gmx.net" target="_blank">c-d.hailfinger.devel.2006@gmx.net</a>></span><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>On 28.07.2009 12:05, René Reuter wrote:<div><div></div><div class="h5"><br>
> I've changed that path already, tried every possibility. I even asked the<br>
> gcc guys if they now any possibility how i could provide the lib, but it<br>
> always crashes.<br>
><br>
<br>
</div></div></div><div><div></div><div class="h5">(Any commands you have to run are preceded by a #)<br>
<br>
It doesn't crash, it just throws an undefined reference error. Looking<br>
at the undefined reference error, it complains EVP_sha256 is missing.<br>
Next question is why that symbol is missing although you had -lcrypto in<br>
the command line. Run the following command:<br>
# grep -l EVP_sha256 /usr/lib/libcrypto*<br>
<br>
Expected output is:<br>
/usr/lib/libcrypto.a<br>
/usr/lib/libcrypto.so<br>
/usr/lib/libcrypto.so.0.9.8<br>
If /usr/lib/libcrypto.a is missing, it can't work (unless you're on<br>
Debian/Ubuntu with that strange lib layout, and if that is the case,<br>
please complain). Now run<br>
# objdump -a /usr/lib/libcrypto.a|grep format<br>
<br>
Expected output is:<br>
cryptlib.o:     file format elf32-i386<br>
mem.o:     file format elf32-i386<br>
mem_clr.o:     file format elf32-i386<br>
mem_dbg.o:     file format elf32-i386<br>
cversion.o:     file format elf32-i386<br>
ex_data.o:     file format elf32-i386<br>
[...]<br>
If the output differs (maybe showing "file format elf64-x86-64"), it<br>
can't work. Now run<br>
#gcc -m32 -Wl,--build-id=none -nostdlib -nostartfiles -L/usr/lib/<br>
-lcrypto -lssl -static -print-file-name=libcrypto.a<br>
<br>
Expected output is:<br>
/usr/lib/gcc/i586-suse-linux/4.2.1/../../../libcrypto.a<br>
Run the objdump command from above for the file listed in the gcc<br>
output. If the file format is not elf32-i386, it can't work.<br>
<br>
<br>
And now the prize question: How did I arrive at the diagnosis above:<br>
Simple. If the linker can't find some symbols, it means the required<br>
library is not where gcc expects it. Three possible reasons for that:<br>
1. wrong library path<br>
2. wrong library type (dynamic instead of static)<br>
3. wrong architecture (x86_64 instead of i386)<br>
Next, I opened the man page for gcc and searched for nostdlib. First hit<br>
explains how to print the file name for any library you want gcc to use.<br>
If that library does not match what gcc needs for linking your specific<br>
project, gcc will  complain during linking.<br>
<div><div></div><div><br>
Regards,<br>
Carl-Daniel<br>
<br>
--<br>
<a href="http://www.hailfinger.org/" target="_blank">http://www.hailfinger.org/</a><br>
<br>
</div></div></div></div></blockquote></div><br>
</blockquote></div><br>