Skip to content

Instantly share code, notes, and snippets.

@uebayasi
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save uebayasi/10c7bc17c75d578caac2 to your computer and use it in GitHub Desktop.

Select an option

Save uebayasi/10c7bc17c75d578caac2 to your computer and use it in GitHub Desktop.

Debugging

Use ld -Map=xxx.map and check the output. (Intuitive, no explanation needed.)

SECTIONS command: *(x y) vs *(x) *(y)

*(x y) merges sections by placing matched sections in the order they found.

*(x) *(y) merges sections by placing sections x first, then y

Handling multiple sections

When multiple sections are declared in one SECTIONS like

.foo : {}
.bar : {}

Which means .bar is placed after .foo. If you just want to merge sections respectively, do

SECTIONS {
  .foo : {}
}

SECTIONS {
  .bar : {}
}

Partial processing

When you specify one section in SECTIONS like

SECTIONS {
  .data : {}
}

ld handles things about .data; other unmatched sections are not processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment