Global layout depends on source file names

Đang mở
#6,618 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
compilers, embedded-iot

Hướng nghiên cứu

Start by reading how TinyGo orders package-level globals and lays them out in .bss, then reproduce the issue with the pico target, examples/serial, and -opt=2, renaming src/runtime/stdio.go as described. Compare the global addresses and TestBinarySize results across builds. Done means file names no longer change global layout or .bss size when the source code is unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The order of package-level globals in .bss depends on the names of the files that refer to them. A file rename, with no code change, can move a global and change the size of .bss.

pico, examples/serial, -opt=2, built from the same source with src/runtime/stdio.go under three names:

file name .bss size machine.Serial address
stdio.go 1516 0x20001230
aa_stdio.go 1520 0x200011e8
zz_stdio.go 1516 0x20001230

With aa_stdio.go, machine.Serial (1 byte) comes before runtime.runqueue and runtime.sleepQueueBaseTime. The 4-byte fields after it then leave sleepQueueBaseTime misaligned, so the linker adds 4 bytes of padding to reach an 8-byte boundary.

The layout is deterministic. Three clean builds give identical .text, .data and .bss. But it is sensitive: #6616 moved the console functions from runtime_rp2.go to stdio.go, and TestBinarySize changed by 4 or 8 bytes of bss on pico and pico2, with no change to code or data.

Ngôn ngữ chính
Go
Star
17.8k
Fork
1.1k
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
380

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tinygo-org/tinygo

Tất cả issue của tinygo-org/tinygo

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.