Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(565)

Issue 7066043: code review 7066043: cmd/ld: use native-endian symbol values in symbol table (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 4 months ago by rsc
Modified:
12 years, 4 months ago
Reviewers:
CC:
ken2, golang-dev
Visibility:
Public.

Description

cmd/ld: use native-endian symbol values in symbol table The Plan 9 symbol table format defines big-endian symbol values for portability, but we want to be able to generate an ELF object file and let the host linker link it, as part of the solution to issue 4069. The symbol table itself, since it is loaded into memory at run time, must be filled in by the final host linker, using relocation directives to set the symbol values. On a little-endian machine, the linker will only fill in little-endian values during relocation, so we are forced to use little-endian symbol values. To preserve most of the original portability of the symbol table format, we make the table itself say whether it uses big- or little-endian values. If the table begins with the magic sequence fe ff ff ff 00 00 then the actual table begins after those six bytes and contains little-endian symbol values. Otherwise, the table is in the original format and contains big-endian symbol values. The magic sequence looks like an "end of table" entry (the fifth byte is zero), so legacy readers will see a little-endian table as an empty table. All the gc architectures are little-endian today, so the practical effect of this CL is to make all the generated tables little-endian, but if a big-endian system comes along, ld will not generate the magic sequence, and the various readers will fall back to the original big-endian interpretation.

Patch Set 1 #

Patch Set 2 : diff -r bcc567c00842 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r be6ca9f6bfe8 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+145 lines, -75 lines) Patch
M doc/go1.1.html View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/cmd/ld/data.c View 1 2 19 chunks +23 lines, -37 lines 0 comments Download
M src/cmd/ld/lib.h View 1 2 2 chunks +1 line, -7 lines 0 comments Download
M src/cmd/ld/symtab.c View 1 2 7 chunks +55 lines, -10 lines 0 comments Download
M src/libmach/sym.c View 1 2 5 chunks +24 lines, -9 lines 0 comments Download
M src/pkg/debug/gosym/pclntab_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/debug/gosym/symtab.go View 1 3 chunks +10 lines, -2 lines 0 comments Download
M src/pkg/runtime/symtab.c View 1 2 8 chunks +22 lines, -9 lines 0 comments Download

Messages

Total messages: 2
rsc
Hello ken2 (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 4 months ago (2013-01-04 22:03:52 UTC) #1
rsc
12 years, 4 months ago (2013-01-04 22:04:04 UTC) #2
*** Submitted as https://code.google.com/p/go/source/detail?r=8bbc0bdf832e ***

cmd/ld: use native-endian symbol values in symbol table

The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://codereview.appspot.com/7066043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b