Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions workloads/eclair/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN find eclair-node/target -name "eclair-node-*-bin.zip" \
-exec unzip {} -d /opt \; && \
mv /opt/eclair-node-* /opt/eclair

# Build the eclair-sancov Java agent.
# Build the eclair-sancov coverage instrumenter and runtime.
COPY workloads/eclair/eclair-sancov/ /eclair-sancov/
WORKDIR /eclair-sancov
RUN mvn package
Expand All @@ -59,13 +59,13 @@ RUN cc -shared -fPIC \
src/main/c/shmutil.c \
-o /usr/local/lib/libeclair-sancov.so

# Count instrumentable Eclair methods to determine TARGET_MAP_SIZE.
# EclairEdgeCounter scans the same fr/acinq/eclair/ methods that
# EclairTransformer will instrument, so the count matches exactly.
RUN java -cp target/eclair-sancov-0.0.0.jar EclairEdgeCounter \
$(find /opt/eclair/lib -name "*.jar" | tr '\n' ' ') \
# Instrument Eclair's JARs in place; the probe count becomes TARGET_MAP_SIZE.
# The probes call EclairSanCov, placed in lib/ because eclair-node.sh puts
# that directory itself on the classpath.
RUN java -cp target/eclair-sancov-0.0.0.jar EclairInstrumenter /opt/eclair/lib \
> /tmp/eclair-edge-count.txt && \
echo "Eclair edge count: $(cat /tmp/eclair-edge-count.txt)"
cp target/classes/EclairSanCov.class /opt/eclair/lib/ && \
echo "Eclair probe count: $(cat /tmp/eclair-edge-count.txt)"

# Copy smite workspace files and build all scenario binaries
WORKDIR /smite
Expand Down Expand Up @@ -106,8 +106,7 @@ COPY --from=builder /opt/eclair /opt/eclair
COPY --from=builder /usr/local/bin/bitcoind /usr/local/bin/bitcoind
COPY --from=builder /usr/local/bin/bitcoin-cli /usr/local/bin/bitcoin-cli

# Copy coverage agent and JNI shared library
COPY --from=builder /eclair-sancov/target/eclair-sancov-0.0.0.jar /eclair-sancov.jar
# Copy the JNI library EclairSanCov uses to map the AFL shared memory
COPY --from=builder /usr/local/lib/libeclair-sancov.so /usr/local/lib/libeclair-sancov.so

# Copy crash handlers and eclair scenario binary
Expand Down
47 changes: 7 additions & 40 deletions workloads/eclair/eclair-sancov/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,22 @@
</properties>

<dependencies>
<!-- Bytecode manipulation library used by EclairTransformer to rewrite class files -->
<!-- Bytecode manipulation library used by EclairInstrumenter to rewrite class files -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.7</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>9.7</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Set Java agent manifest attributes -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestEntries>
<!-- Tells JVM which class has premain() when -javaagent: is used -->
<Premain-Class>EclairSanCov</Premain-Class>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- Bundle ASM into a fat JAR so no classpath setup is needed at runtime -->
<!-- Bundle ASM into a fat JAR so EclairInstrumenter runs with a single -cp entry -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -54,29 +44,6 @@
</goals>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<!--
Relocate ASM to avoid classpath conflicts with Eclair's bundled ASM jar.
Java agents are appended to the system classpath after the application, so without
relocation the JVM would load Eclair's ASM first, causing ClassReader to fail
on class files compiled beyond Java 8 (the max supported by Eclair's ASM 5.x).
Relocation rewrites all bytecode references in our compiled classes so they use
this private copy of ASM regardless of what version Eclair ships.
-->
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>eclair.sancov.asm</shadedPattern>
</relocation>
</relocations>
<!-- Re-apply agent manifest entries after shading replaces the JAR -->
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Premain-Class>EclairSanCov</Premain-Class>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
Expand Down
2 changes: 1 addition & 1 deletion workloads/eclair/eclair-sancov/src/main/c/shmutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// to read/write coverage counters directly at this address, avoiding the bounds
// check and field load overhead of DirectByteBuffer.get/put.
//
// Called once from EclairSanCov.premain() before any class transformation.
// Called once from EclairSanCov's static initializer, on the first probe.
JNIEXPORT jlong JNICALL Java_EclairSanCov_mapShmAddr(JNIEnv *env, jclass cls,
jint shmId) {
void *ptr = shmat((int)shmId, NULL, 0);
Expand Down
105 changes: 0 additions & 105 deletions workloads/eclair/eclair-sancov/src/main/java/EclairEdgeCounter.java

This file was deleted.

Loading
Loading