Data sections.

Allows the linker to discard any unused data.

Change-Id: I95d83c43bc84d5d2641ceddd8fbb0936d018c703
diff --git a/build/BUILD.gn b/build/BUILD.gn
index 01c7a40..cd5feb1 100644
--- a/build/BUILD.gn
+++ b/build/BUILD.gn
@@ -36,7 +36,6 @@
       "-fno-builtin",
       "-ffreestanding",
       "-fpic",
-      "-ffunction-sections",
     ]
 
     defines += [
@@ -60,6 +59,13 @@
   }
 }
 
+config("sections") {
+  cflags = [
+    "-ffunction-sections",
+    "-fdata-sections",
+  ]
+}
+
 config("lto") {
   cflags = [ "-flto" ]
 }
diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn
index c211f2c..b4100be 100644
--- a/build/BUILDCONFIG.gn
+++ b/build/BUILDCONFIG.gn
@@ -53,6 +53,7 @@
 # All binary targets will get this list of configs by default
 _shared_binary_target_configs = [
   "//build:compiler_defaults",
+  "//build:sections",
   "//build:lto",
 ]
 
diff --git a/build/image/generate_offsets.gni b/build/image/generate_offsets.gni
index 267eb6c..74f3c1b 100644
--- a/build/image/generate_offsets.gni
+++ b/build/image/generate_offsets.gni
@@ -23,7 +23,10 @@
                            ])
 
     # Disable LTO so we get an object file.
-    configs -= [ "//build:lto" ]
+    configs -= [
+      "//build:sections",
+      "//build:lto",
+    ]
     defines = [ "GEN_OFFSETS" ]
     visibility = [ ":${header_target}" ]
   }