To make things more clear…
By binding attribute location, you tell linker where to locate that particular attribute, so that you can access it by its address (i.e. index). The other two ways of addressing attributes is:
- by querying it with glGetAttribLocation() (if we didn’t specify the location by glBindAttribLocation and let linker assign it)
- by defining in the shader explicitly by layout(location = x).
So it is true that glBindAttribLocation() can be called even before a vertex shader is attached to a program object, but it must be done before linking the program. If you want to change the location you need to relink the program.