Calculate crc of sections.

Close #1.
This commit is contained in:
James Benton 2016-01-05 15:44:55 -08:00
parent 9f6e28ea92
commit 9cd1940bc8
3 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ CFILES := $(foreach dir,$(SOURCE),$(wildcard $(dir)/*.cpp))
INCLUDES := $(foreach dir,$(INCLUDE),-I$(dir)) INCLUDES := $(foreach dir,$(INCLUDE),-I$(dir))
CFLAGS := -O2 -Wall --std=c++14 CFLAGS := -O2 -Wall --std=c++14
LDFLAGS := LDFLAGS := -lz
all: $(TARGET) all: $(TARGET)

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <zlib.h>
#include "elf.h" #include "elf.h"
#pragma pack(push, 1) #pragma pack(push, 1)
@ -896,8 +897,8 @@ write(ElfFile &file, const std::string &filename)
auto crc = 0u; auto crc = 0u;
if (!section->data.empty()) { if (!section->data.empty()) {
// TODO: Calculate crc of section->data crc = crc32(0, Z_NULL, 0);
crc = 0xBEEFB00B; crc = crc32(crc, reinterpret_cast<Bytef *>(section->data.data()), section->data.size());
} }
sectionCRCs.push_back(crc); sectionCRCs.push_back(crc);

View File

@ -2,7 +2,7 @@ WUT_ROOT := $(CURDIR)/../..
TARGET := readrpl TARGET := readrpl
SOURCE := . SOURCE := .
INCLUDE := ../common ../ext/cppformat ../ext/zlib INCLUDE := ../common ../ext/cppformat
CXX := g++ CXX := g++