binfmt_misc: add detection for 386

Detects x86 32-bit architectures

Signed-off-by: Tibor Vass <tibor@docker.com>
docker-19.03
Tibor Vass 2019-08-06 01:03:20 +00:00
parent 6de5e9b1ea
commit d8f78dca34
6 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,8 @@
// +build !386
package binfmt_misc
// This file is generated by running make inside the binfmt_misc package.
// Do not edit manually.
const Binary386 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\xd8\x31\x6e\xc2\x30\x14\x06\xe0\xdf\x8d\xdb\x26\x6a\x07\x1f\x20\xaa\x3a\x74\xe8\x64\xb5\x52\xae\x00\x2c\x88\x8d\x03\x80\x14\xc1\x94\x44\x89\x91\x60\x22\x47\x60\xe0\x20\x8c\x8c\x5c\x80\x13\x70\x19\xf4\xe2\x67\x91\x81\x25\xfb\xfb\xa4\x5f\x16\xcf\xe6\x29\xeb\x7b\xfb\xd1\x74\xac\x94\x42\xf0\x82\x08\xdd\xaf\x83\x8e\x33\x00\x7f\xc6\xd7\x33\x7c\x23\xc2\x2f\x74\xb8\x27\xad\x8e\x29\x27\x00\x14\x4d\x35\x03\x7f\x6f\x7c\x0f\x4a\x02\x80\xf2\xca\x75\x7a\x77\xa4\xb4\x3a\xa6\xa4\x00\x52\xfe\x7f\xc8\x27\xbf\x9f\xcc\xe6\xd4\xef\x42\xb5\xc7\x57\x0a\x21\x84\x10\x42\x08\x21\x84\x10\x62\x88\x33\x0d\xd5\xff\xb7\x6b\x0b\xdb\xac\x1b\x57\xbb\xc5\x12\xb6\x28\x5d\x6e\x57\xc5\xc6\x56\x75\x59\xe5\xb5\xdb\xc1\xba\x7c\xeb\x86\xf4\xfd\x00\xf0\xde\xed\x13\x78\xce\xe7\x19\x3f\xd0\x7c\x7e\xf1\x5c\xff\xc6\x3b\x07\x18\xbf\x2b\x08\x54\xef\x8c\x7a\xf5\xc4\x00\x3f\x4f\xde\xdd\x03\x00\x00\xff\xff\x8d\xf7\xd2\x72\xd0\x10\x00\x00"

View File

@ -0,0 +1,7 @@
// +build !386
package binfmt_misc
func i386Supported() error {
return check(Binary386)
}

View File

@ -0,0 +1,7 @@
// +build 386
package binfmt_misc
func i386Supported() error {
return nil
}

View File

@ -3,6 +3,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
binutils-arm-linux-gnueabihf \
binutils-aarch64-linux-gnu \
binutils-x86-64-linux-gnu \
binutils-i686-linux-gnu \
binutils-riscv64-linux-gnu \
binutils-s390x-linux-gnu \
binutils-powerpc64le-linux-gnu
@ -13,6 +14,10 @@ FROM base AS exit-amd64
COPY fixtures/exit.amd64.s .
RUN x86_64-linux-gnu-as -o exit.o exit.amd64.s && x86_64-linux-gnu-ld -o exit -s exit.o
FROM base AS exit-386
COPY fixtures/exit.386.s .
RUN i686-linux-gnu-as -o exit.o exit.386.s && i686-linux-gnu-ld -o exit -s exit.o
FROM base AS exit-arm64
COPY fixtures/exit.arm64.s .
RUN aarch64-linux-gnu-as -o exit.o exit.arm64.s && aarch64-linux-gnu-ld -o exit -s exit.o
@ -36,6 +41,7 @@ RUN powerpc64le-linux-gnu-as -o exit.o exit.ppc64le.s && powerpc64le-linux-gnu-l
FROM golang:1.12-alpine AS generate
WORKDIR /src
COPY --from=exit-amd64 /src/exit amd64
COPY --from=exit-386 /src/exit 386
COPY --from=exit-arm64 /src/exit arm64
COPY --from=exit-arm /src/exit arm
COPY --from=exit-riscv64 /src/exit riscv64
@ -43,7 +49,7 @@ COPY --from=exit-s390x /src/exit s390x
COPY --from=exit-ppc64le /src/exit ppc64le
COPY generate.go .
RUN go run generate.go amd64 arm64 arm riscv64 s390x ppc64le && ls -l
RUN go run generate.go amd64 386 arm64 arm riscv64 s390x ppc64le && ls -l
FROM scratch

View File

@ -30,6 +30,9 @@ func SupportedPlatforms() []string {
if p := "linux/s390x"; def != p && s390xSupported() == nil {
arr = append(arr, p)
}
if p := "linux/386"; def != p && i386Supported() == nil {
arr = append(arr, p)
}
if !strings.HasPrefix(def, "linux/arm/") && armSupported() == nil {
arr = append(arr, "linux/arm/v7", "linux/arm/v6")
} else if def == "linux/arm/v7" {
@ -71,6 +74,11 @@ func WarnIfUnsupported(pfs []string) {
printPlatfromWarning(p, err)
}
}
if p == "linux/386" {
if err := i386Supported(); err != nil {
printPlatfromWarning(p, err)
}
}
if strings.HasPrefix(p, "linux/arm/v6") || strings.HasPrefix(p, "linux/arm/v7") {
if err := armSupported(); err != nil {
printPlatfromWarning(p, err)

View File

@ -0,0 +1,6 @@
.global _start
.text
_start:
mov $1, %eax
xor %ebx, %ebx
int $0x80